Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.2k
Improve error handling for in-evaluable refs for discriminator application#10440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
codspeed-hqbot commentedSep 18, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
CodSpeed Performance ReportMerging#10440 willnot alter performanceComparing Summary
|
github-actionsbot commentedSep 18, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
cloudflare-workers-and-pagesbot commentedOct 3, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Deploying pydantic-docs with |
Latest commit: | 113414a |
Status: | ✅ Deploy successful! |
Preview URL: | https://b1d5d5ab.pydantic-docs.pages.dev |
Branch Preview URL: | https://disc-fix-alias.pydantic-docs.pages.dev |
@@ -466,7 +466,6 @@ def populate_defs(core_schema: CoreSchema, json_schema: JsonSchemaValue) -> Json | |||
core_ref = CoreRef(core_schema['ref']) # type: ignore[typeddict-item] | |||
defs_ref, ref_json_schema = self.get_cache_defs_ref_schema(core_ref) | |||
json_ref = JsonRef(ref_json_schema['$ref']) | |||
self.json_to_defs_refs[json_ref] = defs_ref |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is done in theself.get_cache_defs_ref_schema(core_ref)
call, so no reason to do that here.
pydantic/json_schema.py Outdated
while '$ref' in choice: | ||
assert isinstance(choice['$ref'], str) | ||
choice = self.get_schema_from_definitions(JsonRef(choice['$ref'])) or {} | ||
choice = self.resolve_schema_to_update(choice) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This function handles the above removed logic more gracefully, with an intuitive error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'll try to do a deep dive in the JSON Schema generation process to see what this is about, I'm guessing it is indeed pretty similar to the core schema gen process
Note from my conversation with@adriangb - we could alternatively do a first pass to collect all defs |
4e71e66
intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
This was supposed toclose#8271, but right now it just improves the associated error.
My current hunch is that we need to do an apply discriminators step at the end of json schema building, like we do for core schemas, if we want this to work 😭. Not sure how worth the investment that is, at the moment.
I'd also be open to more creative solutions for evaluating refs for which we have not yet generated the schemas. Probably a good conversation to have with@Viicos and@adriangb.
MRE, at the moment: