Mask nested entities when writing bulk audit-log entries - #70890
Merged
potiuk merged 2 commits intoAug 3, 2026
Conversation
potiuk
requested review from
bugraoz93,
choo121600,
ephraimbuddy,
henry3260,
jason810496,
pierrejeambrun,
rawwar and
shubhamraj-git
as code owners
August 1, 2026 02:39
amoghrajesh
approved these changes
Aug 3, 2026
amoghrajesh
left a comment
Contributor
There was a problem hiding this comment.
One future enhancement, otherwise LGTM.
The audit-log maskers for Variables and Connections dispatch on top-level key names. A bulk request body has exactly one top-level key, `actions`, and the entities sit two levels down in `actions[].entities[]` -- so neither `val`/`value` nor `extra` was ever seen, and the payload was recorded as supplied. Reach the entities before applying the existing per-entity masking. Bare id/key strings in a `delete` action carry nothing to mask and are left as they are.
The masker runs on the raw request body before validation, so extra can arrive as any JSON type. json.loads raises TypeError rather than JSONDecodeError for a non-string, which escaped the audit-log path entirely. Bulk bodies newly reach this branch, so the shape is now reachable where it previously was not.
potiuk
force-pushed
the
mask-entities-in-bulk-audit-log-entries
branch
from
August 3, 2026 23:00
21147f3 to
4450635
Compare
Contributor
Backport failed to create: v3-3-test. View the failure log Run detailsNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
You can attempt to backport this manually by running: cherry_picker fc8d6d8 v3-3-testThis should apply the commit to the v3-3-test branch and leave the commit in conflict state marking After you have resolved the conflicts, you can continue the backport process by running: cherry_picker --continueIf you don't have cherry-picker installed, see the installation guide. |
1 task
potiuk
added a commit
that referenced
this pull request
Aug 4, 2026
…70890) (#71043) The audit-log maskers for Variables and Connections dispatch on top-level key names. A bulk request body has exactly one top-level key, `actions`, and the entities sit two levels down in `actions[].entities[]` -- so neither `val`/`value` nor `extra` was ever seen, and the payload was recorded as supplied. The masker also runs on the raw request body before validation, so `extra` can arrive as any JSON type. `json.loads` raises `TypeError` rather than `JSONDecodeError` for a non-string, which escaped the audit-log path entirely. Bulk bodies newly reach this branch, so the shape is now reachable where it previously was not. (cherry picked from commit fc8d6d8)
vatsrahul1001
pushed a commit
that referenced
this pull request
Aug 5, 2026
…70890) (#71043) The audit-log maskers for Variables and Connections dispatch on top-level key names. A bulk request body has exactly one top-level key, `actions`, and the entities sit two levels down in `actions[].entities[]` -- so neither `val`/`value` nor `extra` was ever seen, and the payload was recorded as supplied. The masker also runs on the raw request body before validation, so `extra` can arrive as any JSON type. `json.loads` raises `TypeError` rather than `JSONDecodeError` for a non-string, which escaped the audit-log path entirely. Bulk bodies newly reach this branch, so the shape is now reachable where it previously was not. (cherry picked from commit fc8d6d8)
dabla
pushed a commit
to dabla/airflow
that referenced
this pull request
Aug 14, 2026
* Mask nested entities when writing bulk audit-log entries The audit-log maskers for Variables and Connections dispatch on top-level key names. A bulk request body has exactly one top-level key, `actions`, and the entities sit two levels down in `actions[].entities[]` -- so neither `val`/`value` nor `extra` was ever seen, and the payload was recorded as supplied. Reach the entities before applying the existing per-entity masking. Bare id/key strings in a `delete` action carry nothing to mask and are left as they are. * Tolerate a non-string connection extra when masking audit-log entries The masker runs on the raw request body before validation, so extra can arrive as any JSON type. json.loads raises TypeError rather than JSONDecodeError for a non-string, which escaped the audit-log path entirely. Bulk bodies newly reach this branch, so the shape is now reachable where it previously was not.
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.
The audit-log maskers for Variables and Connections dispatch on top-level key
names --
val/valuefor variables,extrafor connections. A bulk requestbody has exactly one top-level key,
actions, and the entities sit two levelsdown in
actions[].entities[], so neither masker ever saw a key it recognisedand the payload was recorded as supplied. The single-entity endpoints mask the
same fields correctly; only the bulk paths diverged.
Approach
_mask_bulk_entitieswalksactions[].entities[]and applies the existingper-entity masking to each entry, so the two shapes now agree. The per-entity
logic is unchanged and simply factored out (
_mask_connection_entity,_mask_variable_entity) so both call sites share it.deleteaction may list bare id/key strings rather than entity objects;those carry nothing to mask and are passed through.
Nonefor a non-bulk body so the flat path is untouched.(
actionsnot a list, missingentities, non-dict actions) must not raise --each is covered by a test.
Worth noting for connections: a nested
passwordwas already covered, but onlywhile
hide_sensitive_var_conn_fieldsis enabled, since that is key-nameredaction.
extrawas never covered by it -- the name is not a recognisedsensitive field and the value is a JSON string, which
redactreturnsunchanged. Masking
extrahere is structural and so does not depend on thatsetting.
Test plan
TestMaskBulkFields-- bulk variables, bulk connectionextra, multipleactions/entities, delete-by-key, and five malformed shapes
guard tests correctly pass either way
test_decorators.py-- 30 passedtest_variables.py+test_connections.py-- 230 passedruff check/ruff formatcleanWas generative AI tooling used to co-author this PR?
Generated-by: Claude Opus 5 (1M context) following the guidelines at
https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions