[CDF-28123] fix(graphql): exclude extra YAML fields from upsertGraphQlDmlVersion mutation variables#3113
Conversation
## Bump - [x] Patch - [ ] Skip ## Changelog ### Fixed - `cdf build` rejecting unquoted timestamp-like values in config.yaml variables
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the GraphQL data model creation payload by using dump(exclude_extra=True) instead of model_dump to prevent forwarding extra YAML keys to the GraphQL mutation variables, which avoids API rejection errors. It also adds regression tests to verify that extra fields are excluded, unset optional fields are omitted, and explicitly set optional fields are preserved in the payload. I have no feedback to provide as there are no review comments.
d6603a8 to
5bf067b
Compare
☂️ Code Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3113 +/- ##
==========================================
+ Coverage 86.01% 86.02% +0.01%
==========================================
Files 475 475
Lines 44300 44319 +19
==========================================
+ Hits 38103 38124 +21
+ Misses 6197 6195 -2
🚀 New features to boost your workflow:
|
…mutation variables model_dump(exclude_unset=False) forwarded any extra key in the source YAML (stored in __pydantic_extra__ via extra="allow") as part of dmCreate. The CDF API rejects unknown fields on GraphQlDmlVersionUpsert and returns upsertGraphQlDmlVersion=null, producing a cryptic Pydantic "Input should be an object" error that masks the real rejection reason. Switch to item.dump(exclude_extra=True) which strips __pydantic_extra__ and also omits unset optional nulls (preserveDml, previousVersion, etc.) for a clean, minimal payload. Explicitly set YAML fields (previousVersion, preserveDml, name, description) are still forwarded as before.
5bf067b to
ef5ba71
Compare
…lDmlVersion mutation variables (#3114) Empty commit to re-trigger the release job for #3113. The squash merge of #3113 produced a commit with an empty body, so the release script could not find the `## Bump` marker and exited with code 1. ## Bump - [x] Patch - [ ] Skip ## Changelog ### Fixed - `cdf deploy` for GraphQL data models no longer sends extra or unknown YAML keys to the `upsertGraphQlDmlVersion` mutation, and now surfaces the real API error message instead of an opaque Pydantic `"Input should be an object"` crash.
…lDmlVersion mutation variables (#3115) Empty commit to trigger the release for #3113 and #3114 (both had malformed commit bodies). ## Bump - [x] Patch - [ ] Skip ## Changelog ### Fixed - `cdf deploy` for GraphQL data models no longer sends extra or unknown YAML keys to the `upsertGraphQlDmlVersion` mutation, and now surfaces the real API error message instead of an opaque Pydantic validation crash.
Description
model_dump(exclude_unset=False)increate()forwarded every key in the sourceYAML — including any key not declared in
GraphQLDataModelRequest— as part of thedmCreatemutation variables. BecauseBaseModelObjectusesextra="allow", unknownYAML keys land in
__pydantic_extra__and are serialised verbatim bymodel_dump.The CDF GraphQL API rejects unknown fields on
GraphQlDmlVersionUpsertand returns:{"data": {"upsertGraphQlDmlVersion": null}, "errors": [{"message": "...real reason..."}]}The client then crashes with a cryptic Pydantic
"Input should be an object"error,completely masking the real rejection reason.
Fix: switch to
item.dump(exclude_extra=True)which strips__pydantic_extra__and omits unset optional nulls (
preserveDml,previousVersion, etc.) for a clean,minimal payload. Fields the user explicitly set in their YAML
(
previousVersion,preserveDml,name,description) are still forwarded.Related: superseedes/incorporates #3088
that is now closed.
Bump
Changelog
Fixed
cdf deployfor GraphQL data models no longer sends extra or unknown YAML keysto the
upsertGraphQlDmlVersionmutation, preventing the CDF API from rejectingthe request and returning an opaque
"Input should be an object"Pydantic error.