Skip to content

Keep the URL scheme out of path masking in airflow info --anonymize - #73599

Merged
henry3260 merged 1 commit into
apache:mainfrom
wiasliaw:anonymizer-keep-scheme-out-of-path-masking
Sep 23, 2026
Merged

henry3260 merged 1 commit into
apache:mainfrom
wiasliaw:anonymizer-keep-scheme-out-of-path-masking

Conversation

@wiasliaw

Copy link
Copy Markdown
Contributor

Why

#73179 made airflow info --anonymize mask a netloc-less connection string by handing the whole value to process_path, whose username substitution is an unanchored substring replacement — so the scheme itself is in the replacement's reach. An OS username that happens to be a substring of the scheme corrupts the report:

username "lite":  sqlite:////home/lite/airflow.db  ->  sq${USER}:///${HOME}/airflow.db
username "db":    duckdb:////home/db/wh.duckdb     ->  duck${USER}:///${HOME}/wh.duck${USER}

This was called out as an optional follow-up in the review of #73179.

What

airflow-core/src/airflow/cli/commands/info_command.py — the netloc-less branch of PiiAnonymizer.process_url now splits the value on the first colon and masks only what follows, so the scheme is out of the substitution's reach. Output is byte-identical for every realistic input (checked against the Docker sqlite:////opt/${USER}/${USER}.db case, sqlite:///:memory:, sqlite://); a side effect is that non-URL fallback values such as NOT AVAILABLE are no longer touched by the substitution either.

Covered by a new parametrized test that mocks getuser/expanduser to force the colliding usernames; all three cases fail without the change, and the existing test_should_remove_pii_from_url cases are unchanged.

No newsfragment: CLI output fix, not a major or breaking change.

related: #73179

Verification

Run the anonymizer unit tests:

uv run --project airflow-core pytest airflow-core/tests/unit/cli/commands/test_info_command.py::TestPiiAnonymizer -v

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

Generated-by: Claude Code (Fable 5) following the guidelines

Since apache#73179 a netloc-less connection string is masked through the
unanchored username substitution, so an OS username that happens to be
a substring of the scheme (e.g. "lite" or "db") corrupts the scheme
itself: "sqlite:" becomes "sq${USER}:". Splitting on the first colon
puts the scheme out of the substitution's reach; non-URL fallback
values such as "NOT AVAILABLE" stay intact for the same reason.

Suggested as an optional follow-up in the review of apache#73179.

@henry3260 henry3260 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the fix!

@ColtenOuO ColtenOuO 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, Greet work! Let's wait for CI green.

@henry3260
henry3260 merged commit 8b4e4df into apache:main Sep 23, 2026
73 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Backport failed to create: v3-3-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
❌ v3-3-test Commit Link

You can attempt to backport this manually by running:

cherry_picker 8b4e4df v3-3-test

This should apply the commit to the v3-3-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.

@github-actions github-actions Bot added this to the Airflow 3.3.3 milestone Sep 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi maintainer, this PR was merged without a milestone set.
We've automatically set the milestone to Airflow 3.3.3 based on: backport label targeting v3-3-test
If this milestone is not correct, please update it to the appropriate milestone.

This comment was generated by Milestone Tag Assistant.

@Eason09053360

Copy link
Copy Markdown
Contributor

Thanks @wiasliaw for picking this :)

potiuk pushed a commit that referenced this pull request Sep 23, 2026
…#73179, #73599) (#73603)

* Mask the SQLite database path in airflow info --anonymize (#73179)

The whole point of --anonymize is that the report is safe to paste into a
public bug report. SQLite is the default backend, so the people most likely
to rely on that promise are exactly the ones it was broken for.

Co-authored-by: Eason09053360 <[email protected]>
(cherry picked from commit 41480ac)

* Keep the URL scheme out of path masking in airflow info --anonymize (#73599)

Since #73179 a netloc-less connection string is masked through the
unanchored username substitution, so an OS username that happens to be
a substring of the scheme (e.g. "lite" or "db") corrupts the scheme
itself: "sqlite:" becomes "sq${USER}:". Splitting on the first colon
puts the scheme out of the substitution's reach; non-URL fallback
values such as "NOT AVAILABLE" stay intact for the same reason.

Suggested as an optional follow-up in the review of #73179.

(cherry picked from commit 8b4e4df)

---------

Co-authored-by: Y-C <[email protected]>
Co-authored-by: Eason09053360 <[email protected]>
Co-authored-by: wiasliaw <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants