fix: boolean false values dropped in form submissions#3776
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 87ba54d7ae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if stripped.lower() in ("true", "false"): | ||
| v = stripped.lower() == "true" |
There was a problem hiding this comment.
Avoid coercing every "true"/"false" string to bool
In api_launch form mode, this unconditional conversion changes any user-entered "true"/"false" string into a boolean before tool validation, even when the target parameter is typed as str. That creates a regression for string inputs (for example a str field set to "false" now arrives as False and fails Pydantic string validation), so boolean parsing should be gated by the argument schema/type instead of applied globally.
Useful? React with 👍 / 👎.
| if field_info.default is not pydantic.fields.PydanticUndefined: | ||
| data[name] = field_info.default | ||
| else: | ||
| data[name] = False |
There was a problem hiding this comment.
Respect default_factory when backfilling boolean defaults
_backfill_boolean_defaults says it backfills from model defaults, but this branch only checks field_info.default; for boolean fields declared with Field(default_factory=...), default is PydanticUndefined, so missing input is forced to False instead of using the configured factory value. That silently overrides model behavior for omitted checkbox fields and can invert defaults in production forms.
Useful? React with 👍 / 👎.
Test Failure AnalysisSummary: One test timed out on Windows Python 3.10 — Root Cause: The failing test spawns a Python subprocess via stdio transport (an MCP proxy server), which can be slow to start on Windows. The unit test timeout is 5 seconds, which is occasionally not enough for subprocess startup + FastMCP import on Windows CI runners. All other platforms (Ubuntu Python 3.10 and 3.13) passed. Suggested Solution: This appears to be pre-existing Windows flakiness in
Detailed AnalysisFailing test: Timeout log excerpt: What the test does: Creates an Why it's unrelated to this PR: The PR diff only touches:
None of these are in the proxy, transport, or MCP config code paths. Other passing jobs:
Related Files
|
HTML checkboxes don't send a value when unchecked, so Prefab UI forms omit boolean fields entirely from the submitted data. This caused
submit_formto fail with a "Missing required argument" error even when the boolean field had a Pydantic default.Two fixes:
In
form.py, thesubmit_formtool now backfills missing boolean fields with their model defaults (orFalse) before Pydantic validation. Thedataparameter also defaults toNoneso the tool doesn't reject an empty argument dict outright.In
apps_dev.py, the dev server's form handler now parses"true"/"false"strings into actual booleans instead of dropping them during the empty-string filter.Closes #3769