Skip to content

func_to_form_spec copies non-JSON-serializable defaults (Enum, date, object) into the schema #15

Closed

Description

@thorwhalen

Found by the adversarial review of i2mint/uf#6.

func_to_form_spec (via the function-to-schema path) copies a parameter's raw Python default into the JSON Schema default. For an Enum member, a datetime.date, or any arbitrary object, the resulting spec is not JSON-serializable. In uf this makes /api/functions/<name>/spec return 500 {"error": "Object of type Color is not JSON serializable"}.

Repro:

import enum, json
from ju.rjsf import func_to_form_spec
class Color(enum.Enum):
    red = 'red'
def f(c: Color = Color.red): ...
json.dumps(func_to_form_spec(f, nest_under_field=None))  # TypeError

Suggested: map defaults through a JSON-coercion step (Enum → .value plus enum list; date/datetime → ISO string; otherwise drop the default rather than emit something unserializable). Until i2mint/uf#6, uf users on runners without dill silently got uf's basic fallback, so this rarely surfaced through uf.

Activity

  1. added a commit that references this issue on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions