Skip to content

Conversation

@devdattatalele
Copy link
Contributor

@devdattatalele devdattatalele commented Dec 2, 2025

Problem

When defining Python scripts with list[dict] or untyped array parameters, user-defined JSON schema properties are lost upon saving as draft or deploying. This prevents users from creating proper UI forms for complex data structures like message arrays for LLM calls.

Resolves #7209

According to comments made following changes

Frontend:

  • cli/windmill-utils-internal/src/parse/parse-schema.ts:
    • Lines 209-222: Preserve ALL items fields when parser cannot infer structure
    • Line 210: Preserve items.type instead of hardcoding "object"
    • Lines 225-230: Preserve items for untyped lists
    • Line 234: Use nullish coalescing (??) for correct type preservation

Testing

Test Case 1: list[dict] with properties and required fields

def main(messages: list[dict]):
    return messages
  • Define properties and required fields via UI
  • Save draft → All fields preserved ✅

Test Case 2: Untyped array parameter

def main(messages):
    return messages
  • Define type: "array" with properties via UI
  • Save draft → Type remains "array" ✅

Test Case 3: Backward compatibility

  • Existing schemas without manual properties → No change ✅

Breaking Changes

None. This change only preserves user-defined fields when they exist.

Fixes issue where JSON schema properties manually defined in the UI are
lost when saving Python scripts with list[dict] or untyped array parameters.

Changes:
- Preserve all items fields (properties, required, additionalProperties, etc.)
- Preserve items.type instead of hardcoding "object"
- Preserve type for untyped parameters using nullish coalescing
- Add type safety check for items preservation

The Python parser cannot infer object properties from list[dict] annotations.
This fix preserves user-defined schema fields when parser cannot infer structure.

Fixes windmill-labs#7209
Address bot feedback for consistency. The untyped list branch now preserves
all user-defined fields (required, additionalProperties, enum, etc.) just
like the record[] branch, instead of only preserving properties.

This ensures users who define required fields or enum values for untyped
list parameters don't lose that data on save.

Related to windmill-labs#7209
@devdattatalele
Copy link
Contributor Author

Fixed the inconsistency. The untyped list branch now preserves all user-defined fields (required, additionalProperties, enum, resourceType, contentEncoding, description) just like the record[] branch, instead of only preserving properties.

This ensures complete schema preservation regardless of whether the list is typed (list[dict]) or untyped.

@rubenfiszel
Copy link
Contributor

@hugocasa could you check please

} else {
newS.type = "object";
// Preserve existing type when inference fails, default to "object" for undefined/null
newS.type = oldS.type ?? "object";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rubenfiszel are you ok with this? right now we fallback to "object" when we the type can't be parsed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that feels reasonable, but we may want to try how it behave with a few real world examples of typing live and see the result with new behavior and old behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Always lost json schema define for generated ui for python

3 participants