Repository navigation
Fix: don’t drop real title fields when optimising schema - #2324
Merged
mertunsall merged 6 commits intoJul 7, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
cubic reviewed 2 files and found no issues. Review PR in cubic.dev.
ai-christianson
force-pushed
the
2025-07-06-fix-schema-optimizer
branch
from
July 6, 2025 21:28
8feb520 to
8430f21
Compare
ai-christianson
marked this pull request as draft
July 6, 2025 21:39
ai-christianson
marked this pull request as ready for review
July 6, 2025 21:49
Contributor
There was a problem hiding this comment.
cubic reviewed 3 files and found no issues. Review PR in cubic.dev.
ai-christianson
commented
Jul 6, 2025
Contributor
|
Great catch! Thanks a lot for this PR! |
pirate
reviewed
Jul 7, 2025
Contributor
There was a problem hiding this comment.
this should probably be in tests/ci/ not in controller/tests
soyun11
pushed a commit
to soyun11/browser-use
that referenced
this pull request
May 15, 2026
…se#2324) ### What happened? When `SchemaOptimizer` cleans up a Pydantic JSON-Schema it throws away every `"title"` key, assuming it’s just the auto-generated object label. That’s fine—until you have a real model field *also* called `title`. In that case the field silently disappears from the optimised schema, breaking strict-mode validation downstream (see failing test in this patch). **tl;dr** without this patch, an output schema with a `title` field gets broken by the schema optimizer. ### The fix (tiny but robust) * Track whether the optimiser is currently iterating over a `properties` map. * Skip `"title"` **only** when we’re *not* inside `properties` (i.e. only for metadata titles). * Net code change: ~5 logical lines; no API surface touched. ```python # before if key == "title": continue # after if key == "title" and not in_properties: continue ``` ### Why this is safe to merge * Works for *any* model that has a field named `title`—no project-specific assumptions. * No side-effects: `$ref` flattening, `anyOf` handling, and strict-mode logic are untouched. * Added regression test fails on `main`, passes with this patch: ```python class Foo(BaseModel): title: str value: int ``` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixed a bug where the schema optimizer removed real model fields named `title`, causing them to disappear from the output schema. - **Bug Fixes** - Now only skips metadata `title` keys, not actual fields inside `properties`. - Added a regression test to ensure all fields are preserved. <!-- End of auto-generated description by cubic. -->
This was referenced Aug 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What happened?
When
SchemaOptimizercleans up a Pydantic JSON-Schema it throws away every"title"key, assuming it’s just the auto-generated object label.That’s fine—until you have a real model field also called
title.In that case the field silently disappears from the optimised schema, breaking
strict-mode validation downstream (see failing test in this patch).
tl;dr without this patch, an output schema with a
titlefield gets broken by the schema optimizer.The fix (tiny but robust)
propertiesmap."title"only when we’re not insideproperties(i.e. only for metadata titles).
Why this is safe to merge
title—no project-specific assumptions.$refflattening,anyOfhandling, and strict-mode logic are untouched.main, passes with this patch:Summary by cubic
Fixed a bug where the schema optimizer removed real model fields named
title, causing them to disappear from the output schema.titlekeys, not actual fields insideproperties.