Skip to content

Stop airflowctl from failing on fields added by newer API servers - #75610

Merged
potiuk merged 1 commit into
apache:mainfrom
Andrushika:allow-extra-fields-in-response-models
Oct 25, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
Andrushika:allow-extra-fields-in-response-models

Conversation

@Andrushika

@Andrushika Andrushika commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Why

airflowctl generates its API models from the core OpenAPI spec.

In core, StrictBaseModel rejects unknown fields. The spec shows this as additionalProperties: false. airflowctl then generates the same model with extra="forbid".

#44306 added StrictBaseModel for request bodies only. Response models do not reject extra fields:

Response models, those are instantiated by the server, there we want to be able to provide 'more' for the model to select only what should be returned.

Seven core models extend StrictBaseModel, but they only appear in responses. They are the three config models and the four asset reference models. If a newer server adds a field to one of them, an older airflowctl cannot read the response.

This happens now. #71446 added the optional team_name field to two of these models in 3.4. airflowctl from airflow-ctl/v0-1-test fails on assets list and assets get against 3.4.0b2 (#57826).

What

The seven models now extend BaseModel. The spec, the UI schemas and the airflowctl models are regenerated. The server sends the same JSON as before.

With the same change on airflow-ctl/v0-1-test, the 3.4.0b2 runs pass again. A backport for 0.1.6 must include the two core files, because that branch generates its models from its own core.

related: #57826


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5.5)

Generated-by: Claude Code (Opus 5.5) following the guidelines

Seven core API models that only appear in responses, the config models
and the asset reference models, extend StrictBaseModel. So the OpenAPI
spec marks them "additionalProperties: false", and the airflowctl
models generated from it get extra="forbid". When a newer server adds
a field to one of them, an older airflowctl fails to parse the
response. apache#71446 added the optional team_name field to two asset
reference models for 3.4, and airflowctl from airflow-ctl/v0-1-test
now fails on "assets list" and "assets get" against 3.4.0b2.

StrictBaseModel is meant for request bodies, so that unknown fields
sent by a client are rejected (apache#44306). Response models are built by
the server, and new fields in them should not break existing clients.
@Andrushika

Copy link
Copy Markdown
Contributor Author

cc @shahar1 :)

@shahar1 shahar1 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.

LGTM. The fix is correct and minimal: I checked the generated spec on main, and these seven are exactly the additionalProperties: false schemas that are reachable only from responses, with no strict schema shared between a request body and a response. The three new airflowctl tests fail with extra_forbidden on the base and pass with the change, and CI is green.

Smaller observations

  • airflow-core/src/airflow/api_fastapi/core_api/base.py:39 — Optional, not blocking. The root cause here is that seven response-only models picked StrictBaseModel. Its docstring says to use it for models that "should not have any extra fields in the payload", which reads as applying to responses too. A one-line note there that it is for request bodies only, because additionalProperties: false in the spec makes generated clients such as airflowctl reject fields that newer servers add, would record the constraint this PR relies on and make the next response model less likely to repeat it. The file is not in the diff, so this can also go in a follow-up.

This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.

More on how Apache Airflow handles maintainer review:
Contributing guide.

@potiuk
potiuk merged commit e990430 into apache:main Oct 25, 2026
151 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Backport failed to create: airflow-ctl/v0-1-test. View the failure log Run details

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
❌ airflow-ctl/v0-1-test Commit Link

You can attempt to backport this manually by running:

cherry_picker e990430 airflow-ctl/v0-1-test

This should apply the commit to the airflow-ctl/v0-1-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

If you don't have cherry-picker installed, see the installation guide.

@Andrushika
Andrushika deleted the allow-extra-fields-in-response-models branch October 25, 2026 23:16
shahar1 pushed a commit that referenced this pull request Oct 27, 2026
…by newer API servers (#75610) (#75754)

Seven core API models that only appear in responses, the config models
and the asset reference models, extend StrictBaseModel. So the OpenAPI
spec marks them "additionalProperties: false", and the airflowctl
models generated from it get extra="forbid". When a newer server adds
a field to one of them, an older airflowctl fails to parse the
response. #71446 added the optional team_name field to two asset
reference models for 3.4, and airflowctl from airflow-ctl/v0-1-test
now fails on "assets list" and "assets get" against 3.4.0b2.

StrictBaseModel is meant for request bodies, so that unknown fields
sent by a client are rejected (#44306). Response models are built by
the server, and new fields in them should not break existing clients.

(cherry picked from commit e990430)
henry3260 added a commit that referenced this pull request Nov 1, 2026
The seven response models that moved back to BaseModel in #75610 had
picked StrictBaseModel because its docstring reads as a general
recommendation: use it where extra fields should not be accepted.

Nothing at the class recorded why that is limited to request bodies. A
response model is instantiated from a source object that holds more than
it returns, so forbidding extra fields rejects its own construction; and
the setting reaches generated clients as additionalProperties: false, so
an older airflowctl rejects a field a newer server adds. The second
reason is what #75610 had to fix, and neither was written down where the
next response model would look.
shahar1 pushed a commit that referenced this pull request Nov 19, 2026
…by newer API servers (#75610) (#75754)

Seven core API models that only appear in responses, the config models
and the asset reference models, extend StrictBaseModel. So the OpenAPI
spec marks them "additionalProperties: false", and the airflowctl
models generated from it get extra="forbid". When a newer server adds
a field to one of them, an older airflowctl fails to parse the
response. #71446 added the optional team_name field to two asset
reference models for 3.4, and airflowctl from airflow-ctl/v0-1-test
now fails on "assets list" and "assets get" against 3.4.0b2.

StrictBaseModel is meant for request bodies, so that unknown fields
sent by a client are rejected (#44306). Response models are built by
the server, and new fields in them should not break existing clients.

(cherry picked from commit e990430)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:airflow-ctl area:API Airflow's REST/HTTP API area:UI Related to UI/UX. For Frontend Developers. backport-to-airflow-ctl/v0-1-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants