Repository navigation
Conversation
B64_REDACTED was the bytes value base64.b64encode(b'REDACTED'), but the passwordHash field of the JSON response is a str, so the comparison was always false and ExportedUserRecord.password_hash returned the "UkVEQUNURUQ=" placeholder instead of None when the service account cannot read password hashes. Make B64_REDACTED a str and feed the existing test a str value, as the API returns it.
There was a problem hiding this comment.
Code Review
This pull request updates the B64_REDACTED constant in firebase_admin/_user_mgt.py to be a decoded string instead of a bytes object. It also updates the test suite to match this change and adds a new test test_list_users_redacted_password_hash to ensure that redacted password hashes are correctly cleared when listing users. There are no review comments, and we have no feedback to provide.
This branch has not been deployed
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.
ExportedUserRecord.password_hashis supposed to returnNonewhen the backend redacts the hash (it sendsbase64("REDACTED"), i.e. the string"UkVEQUNURUQ="). The marker constant wasbase64.b64encode(b'REDACTED'), which isbytes, while the value parsed from the JSON response is astr. In Python 3 these never compare equal, so the placeholder was returned as if it were a real hash.This change makes
B64_REDACTEDastrso the comparison matches what the API actually returns. This is the same comparison the Node.js SDK does.Testing:
test_redacted_passwords_clearedbuilt the record with abytesvalue, which a JSON response can never contain, so it passed even though the real case was broken. It now uses the string form. I also addedtest_list_users_redacted_password_hash, which goes throughauth.list_users()with a mocked JSON response containing one redacted and one real hash. Both tests fail on main and pass with this change.pytest tests/test_user_mgt.pypasses, and./lint.shreports no issues.Fixes #1007
This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.
Context Sources Used: