Skip to content

Validate KubernetesResourceBaseOperator yaml_conf after rendering#70337

Merged
shahar1 merged 2 commits into
apache:mainfrom
1fanwang:fix-k8s-resource-init
Jul 24, 2026
Merged

Validate KubernetesResourceBaseOperator yaml_conf after rendering#70337
shahar1 merged 2 commits into
apache:mainfrom
1fanwang:fix-k8s-resource-init

Conversation

@1fanwang

Copy link
Copy Markdown
Contributor

yaml_conf and yaml_conf_file are template fields, so they are rendered after __init__ runs. The base constructor raised AirflowException when neither was set — a check against the un-rendered values. Move it into a _validate_yaml_conf() helper called from execute() in both the create and delete operators, so the presence check runs after rendering.

related: #70296

Testing Done

New test_missing_yaml_conf_rejected_at_execute constructs both operators with neither field and asserts the AirflowException now surfaces from execute(). It fails on the pre-fix source (the constructor raises first) and passes after. test_resource.py: 12 passed. validate_operators_init.py on the module exits 0; the raise AirflowException count is unchanged.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: GitHub Copilot CLI following the guidelines

yaml_conf and yaml_conf_file are template fields, rendered after __init__ runs.
The base constructor raised when neither was set, acting on the un-rendered
values. Move the presence check into a helper called from execute() in both the
create and delete operators, so it runs after rendering.

related: apache#70296
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
@1fanwang
1fanwang marked this pull request as ready for review July 24, 2026 06:23
@shahar1
shahar1 merged commit 220d219 into apache:main Jul 24, 2026
160 of 165 checks passed
@shahar1 shahar1 removed the backport-to-v3-3-test Backport to v3-3-test label Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools area:providers provider:cncf-kubernetes Kubernetes (k8s) provider related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants