Fix DAG named "DAGs" colliding with the global DAGs permission resource - #69106
Conversation
|
@vincbeck — one judgement call to flag here: I removed the |
I agree, this is a good call, I have no idea why we have this logic in the code at the first place. This code has been sitting there for a while with no real explanation :) |
|
@vincbeck - addressed concerns :) |
resource_name() returned the dag_id unchanged when it equalled a reserved resource name. Because a real dag_id can be "DAGs" (it passes the dag_id validator), a DAG named "DAGs" resolved to the global DAGs resource instead of its own per-DAG "DAG:DAGs" resource, so permissions for that DAG were applied to the wrong resource. Drop the reserved-name short-circuit so a dag_id is always prefixed. The already-prefixed branch (e.g. "DAG:foo") still short-circuits, which is safe because the "DAG:" / "DAG Run:" prefixes contain a colon that the dag_id validator (KEY_REGEX = ^[\w.-]+$) forbids. Mirrored in the airflow-core copy. Generated-by: Claude Opus 4.8 following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
Address @vincbeck's review: remove the explanatory NB comment in resource_name() (the removed short-circuit is self-evident), and trim the regression test down to the single collision assertion in both the core and FAB copies. Generated-by: Claude Code (Opus 4.8)
5bd2d50 to
646207b
Compare
What
resource_name()returned thedag_idunchanged when it equalled a reserved resource name. Because a realdag_idcan beDAGs(it passes thedag_idvalidator), a DAG namedDAGsresolved to the globalDAGspermission resource instead of its own per-DAGDAG:DAGsresource, so that DAG's permissions were applied to the wrong resource.This drops the reserved-name short-circuit so a
dag_idis always prefixed (DAG:<dag_id>). The already-prefixed branch (DAG:foo,DAG Run:foo) still short-circuits — safe because those prefixes contain a colon, which thedag_idvalidator (KEY_REGEX = ^[\w.-]+$) forbids, so no realdag_idcan reach it. The same fix is mirrored in the duplicatedairflow-corecopy.Tests
resource_name("DAGs", RESOURCE_DAG)now returnsDAG:DAGs(FAB + core copies); ordinary and already-prefixed names unchangedproviders/fabtest_security.pysuite passes;ruffcleanWas generative AI tooling used to co-author this PR?
Generated-by: Claude Opus 4.8 following the guidelines at
https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions