fix: keep title keys inside OpenAPI singular example values - #12313
Closed
LHMQ878 wants to merge 7 commits into
Closed
fix: keep title keys inside OpenAPI singular example values#12313LHMQ878 wants to merge 7 commits into
LHMQ878 wants to merge 7 commits into
Conversation
deepset-ai#12037 stopped `_remove_title_from_schema` from misreading the keys of a `properties` mapping as schema keywords. The same reasoning applies to five more keywords whose values are keyed by user-chosen names, and to three whose values are instance data rather than subschemas: - `$defs`, `definitions`: an entry named `title` was deleted, leaving every `$ref` that pointed at it dangling. Pydantic keys `$defs` by class name, so a nested model named `title` reaches this path through the public API and the resulting schema fails validation with `PointerToNowhere`. - `patternProperties`, `dependentSchemas`, `dependentRequired`: a rule keyed on the property name / regex `title` was silently dropped. - `default`, `const`, `enum`: a `title` key inside one of these is part of the *value*. A default of `{"title": "Untitled", "width": 80}` was emitted as `{"width": 80}`, changing the tool's contract. Keywords whose value is a genuine subschema (`items`, `propertyNames`, `additionalProperties`, `anyOf`, ...) keep losing their `title` as before; a test guards that direction too.
Follow up deepset-ai#12219: treat OpenAPI 3.0 example the same as examples so nested title keys survive tool schema stripping.
|
@LHMQ878 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
6 tasks
Contributor
Author
|
Note: this branch was parented on the pre-squash tip of #12219, so GitHub is replaying that PR's commits. I'll rebase onto current |
Contributor
Author
|
Closing temporarily: branch was based on the pre-squash tip of #12219 so the PR incorrectly replayed that history. Will reopen a clean single-commit follow-up rebased on current main. |
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.
Summary
titlewhen it is a name, not a schema keyword #12219: treat OpenAPI 3.0 singularexampleas instance data in_DATA_SCHEMA_KEYWORDS, same asexamples/default/const/enum.titlekeys carried via Pydanticjson_schema_extra={example: ...}when building tool schemas.exampleand a public-API regression throughcreate_tool_from_function.Context
Flagged by @percymcn on #12219 after re-checking the post-merge
3.1.0.devbuild.Test plan
test_remove_title_from_schema_keeps_instance_datapasses with singularexampletest_from_function_with_openapi_example_containing_title_keypassesitems/propertyNames) still remove schema-leveltitle