Reject unknown update_mask fields instead of silently ignoring them - #71003
Open
ColtenOuO wants to merge 1 commit into
Open
Reject unknown update_mask fields instead of silently ignoring them#71003ColtenOuO wants to merge 1 commit into
ColtenOuO wants to merge 1 commit into
Conversation
ColtenOuO
requested review from
bugraoz93,
choo121600,
ephraimbuddy,
henry3260,
jason810496,
pierrejeambrun,
rawwar and
shubhamraj-git
as code owners
August 3, 2026 16:08
ColtenOuO
force-pushed
the
api-reject-unknown-update-mask
branch
from
August 3, 2026 17:41
c6c2495 to
8344c90
Compare
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
update_masklets a PATCH caller say "only apply these fields". Every endpointimplements it by intersecting the mask with the fields present in the body:
An entry that matches no field simply falls out of the intersection. Nothing
notices, so the request becomes a no-op — and still answers
200, echoing backthe untouched record.
A typo is therefore indistinguishable from success:
A stray space does the same thing, since nothing trims the entries:
A client that checks the status code has no way to learn its patch never landed.
dags.pyalready guards against this (if update_mask != ["is_paused"]: raise 400),so rejecting an unusable mask is an established expectation in this API — it was
just missing from the other five places that accept one.
Before / after
?update_mask=value200, applied?update_mask=valu200, not applied400naming the unknown field?update_mask=%20value200, not applied200, appliedThe error names both the offender and the accepted fields:
The change
A single
validate_update_mask()helper inservices/public/common.py, called fromthe five places that accept a mask:
apply_patch_with_update_mask(covers variablesand pools, including their bulk actions), the connections route, the dag-run route,
and the task-instance service.
dags.pyis left alone — it already validates.Two decisions worth flagging:
Aliases count as known names. Validating against field names alone broke an
existing connections test:
ConnectionBody.schema_is aliased toschema, andupdate_mask=["schema","extra"]is a working request today. A caller sends the aliasin the body and reads it back in the response, so it has to be accepted. This PR only
validates the mask — which of the two names a given endpoint acts on is deliberately
left untouched.
Whitespace is trimmed rather than rejected.
pools.pyalready compares withmask.strip(), and the intent of" value"is not in doubt.Note on an existing test
test_patch_dag_run_with_update_maskhad a case asserting that{"update_mask": ["random"]}returns200— the buggy behaviour written down as anexpectation. It now expects
400and the error message.Tests
Four new cases on variables: three unknown-field shapes (a typo, a name that exists
nowhere, an empty string) assert
400and that the row is unchanged, plus oneasserting a mask with surrounding whitespace still applies.
test_variables+test_dag_run: 443 passed.test_pools+test_connections+test_task_instances+test_dags: 684 passed.Was generative AI tooling used to co-author this PR?