Repository navigation
[Python] Fix BigTableEnrichmentHandler None row keys and KeyError text (#41346) - #41698
shikhabhadoria wants to merge 2 commits into
Conversation
Skip Bigtable lookups when the configured row_key field is None instead of querying bNone, report the actual field name when it is missing, and keep None distinct from the string None in cache keys (apache#41346).
There was a problem hiding this comment.
📋 Review Summary
This PR resolves two bugs in BigTableEnrichmentHandler: preventing None lookup values from being coerced to b'None' when querying Bigtable, and fixing the missing-field KeyError message to include the configured row_key field name rather than an empty string. The implementation is well-scoped, avoids rewriting custom row_key_fn KeyErrors, prevents cache key collisions between None and 'None', and includes thorough unit test coverage.
🔍 General Feedback
- The refactoring of empty-row handling into
_handle_empty_rowcleanly unifiesExceptionLevelbehavior (WARN,RAISE,QUIET) betweenNonejoin keys and missing Bigtable rows. - Replacing the import of
_row_key_fnfrombigtable_it_testinbigtable_test.pyremoves an unnecessary coupling to integration test dependencies (liketestcontainers) when running unit tests. - Minor cleanup needed in
CHANGES.mdfor an accidental blank line in the template comment.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
Assigning reviewers: R: @jrmccluskey for label python. This pull request likely touches a core component ("core" label). Please review with scrutiny. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
…ssing Decode the key from row_key_fn for empty-row warnings and treat a None return like a missing join key. Drop the extra blank line in the CHANGES template.
Purpose
Fixes #41346.
BigTableEnrichmentHandlerhad two bugs when resolvingrow_key:Nonejoin key was coerced withstr(None)toNone, so Bigtable was queried for literalb'None'.row_keyfield raisedKeyErrorwith a blank name because the handler interpolated the unsetrow_key_strinstead ofself._row_key.Changes
Nonelookup values like an empty enrichment result and honorExceptionLevel(WARN/RAISE/QUIET) without callingread_row.KeyErrortorequest_dict[self._row_key]and includeself._row_keyin the message (so customrow_key_fnfailures are not rewritten).%ringet_cache_keysoNoneand the string"None"do not share a Redis cache key.Testing
b'None'; blank KeyError text).Nonekeys at eachExceptionLevel, missing-field message,row_key_fnKeyError passthrough, and cache-key distinction.pytestonbigtable_test.py: 8 passedyapf/ruffclean