Skip to content

[CDF-28123] fix(graphql): exclude extra YAML fields from upsertGraphQlDmlVersion mutation variables#3113

Merged
ronpal merged 8 commits into
mainfrom
fix/graphql-upsert-extra-fields-leak
Jul 19, 2026
Merged

[CDF-28123] fix(graphql): exclude extra YAML fields from upsertGraphQlDmlVersion mutation variables#3113
ronpal merged 8 commits into
mainfrom
fix/graphql-upsert-extra-fields-leak

Conversation

@ronpal

@ronpal ronpal commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Description

model_dump(exclude_unset=False) in create() forwarded every key in the source
YAML — including any key not declared in GraphQLDataModelRequest — as part of the
dmCreate mutation variables. Because BaseModelObject uses extra="allow", unknown
YAML keys land in __pydantic_extra__ and are serialised verbatim by model_dump.

The CDF GraphQL API rejects unknown fields on GraphQlDmlVersionUpsert and 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

  • Patch
  • Skip

Changelog

Fixed

  • cdf deploy for GraphQL data models no longer sends extra or unknown YAML keys
    to the upsertGraphQlDmlVersion mutation, preventing the CDF API from rejecting
    the request and returning an opaque "Input should be an object" Pydantic error.

@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

@ronpal

ronpal commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ronpal
ronpal force-pushed the fix/graphql-upsert-extra-fields-leak branch from d6603a8 to 5bf067b Compare July 18, 2026 15:17
@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown

☂️ Code Coverage

current status: ✅

Overall Coverage

Statements Covered Coverage Threshold Status
44319 38124 86% 80% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
cognite_toolkit/_cdf_tk/client/api/graphql_data_models.py 96% 🟢
TOTAL 96% 🟢

updated for commit: ef5ba71 by action🐍

@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.02%. Comparing base (8cda886) to head (ef5ba71).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
..._toolkit/_cdf_tk/client/api/graphql_data_models.py 88.88% 3 Missing ⚠️
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     
Files with missing lines Coverage Δ
..._toolkit/_cdf_tk/client/api/graphql_data_models.py 95.89% <88.88%> (-2.26%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…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.
@ronpal
ronpal force-pushed the fix/graphql-upsert-extra-fields-leak branch from 5bf067b to ef5ba71 Compare July 19, 2026 08:38
@ronpal
ronpal marked this pull request as ready for review July 19, 2026 10:07
@ronpal
ronpal requested review from a team as code owners July 19, 2026 10:07
@ronpal
ronpal merged commit a58bce0 into main Jul 19, 2026
15 checks passed
@ronpal
ronpal deleted the fix/graphql-upsert-extra-fields-leak branch July 19, 2026 10:55
ronpal added a commit that referenced this pull request Jul 19, 2026
…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.
ronpal added a commit that referenced this pull request Jul 19, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants