Skip to content

fix(auth): map password policy violation error - #3291

Open
sean0407 wants to merge 2 commits into
firebase:mainfrom
sean0407:codex/firebase-admin-node-3265-password-policy-error-20261020
Open

sean0407 wants to merge 2 commits into
firebase:mainfrom
sean0407:codex/firebase-admin-node-3265-password-policy-error-20261020

Conversation

@sean0407

@sean0407 sean0407 commented Oct 19, 2026 •

Copy link
Copy Markdown

Summary

  • Map PASSWORD_DOES_NOT_MEET_REQUIREMENTS to the public auth/password-does-not-meet-requirements error code.
  • Add a focused regression test for the server mapping and default error message.

Evidence

  • Before the fix, FirebaseAuthError.fromServerError('PASSWORD_DOES_NOT_MEET_REQUIREMENTS') returned auth/internal-error; the regression failed with that result.
  • The regression now verifies auth/password-does-not-meet-requirements and its default message.
  • An automated review suggested preserving the contiguous INVALID_* block and asserting the default message. Both suggestions were applied in commit 26cff32.
  • test/unit/utils/error.spec.ts: 26 passing.
  • npm run build: passed.
  • ESLint on both changed files and git diff --check: passed.
  • npm run test:unit: 6,147 passing, 8 failing. Failures are HTTP/2 session error assertions in test/unit/utils/api-request.spec.ts and test/unit/messaging/messaging.spec.ts.

Merge Danger

Door: two-way

Blast Radius: limited to the Auth server error mapping for this response code.

Fixes #3265

@sean0407
sean0407 requested a review from a team October 19, 2026 22:24

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a new error code, PASSWORD_DOES_NOT_MEET_REQUIREMENTS, to handle password policy violations, along with its client-side mapping and a corresponding unit test. The feedback suggests reorganizing the placement of the new error code and its configuration in src/auth/error.ts to avoid breaking the contiguous block of INVALID_ error codes, and adding an assertion for the error message in the unit test to ensure consistency.

Comment thread src/auth/error.ts Outdated
INVALID_PASSWORD: 'invalid-password',
INVALID_PASSWORD_HASH: 'invalid-password-hash',
INVALID_PASSWORD_SALT: 'invalid-password-salt',
PASSWORD_DOES_NOT_MEET_REQUIREMENTS: 'password-does-not-meet-requirements',

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.

medium

The PASSWORD_DOES_NOT_MEET_REQUIREMENTS key is currently inserted in the middle of a contiguous block of INVALID_ error codes (lines 39 to 81). To maintain the grouping and readability of the error codes, it should be moved out of the INVALID_ block and placed in alphabetical order among the other error codes (for example, after OPERATION_NOT_ALLOWED and before PHONE_NUMBER_ALREADY_EXISTS).

Comment thread src/auth/error.ts Outdated
Comment on lines +301 to +304
PASSWORD_DOES_NOT_MEET_REQUIREMENTS: {
code: AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS,
message: 'The password does not meet the requirements.',
},

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.

medium

Similarly, PASSWORD_DOES_NOT_MEET_REQUIREMENTS in authClientErrorCode is inserted in the middle of the INVALID_ error code configurations. It should be moved to be grouped with the other non-INVALID_ error codes, such as after OPERATION_NOT_ALLOWED.

Comment on lines +141 to +144
it('should map password policy server errors to the public password policy code', () => {
const error = FirebaseAuthError.fromServerError('PASSWORD_DOES_NOT_MEET_REQUIREMENTS');
expect(error.code).to.be.equal('auth/password-does-not-meet-requirements');
});

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.

medium

To ensure consistency with other test cases in this file, we should also assert that the mapped error message is correct.

Suggested change
it('should map password policy server errors to the public password policy code', () => {
const error = FirebaseAuthError.fromServerError('PASSWORD_DOES_NOT_MEET_REQUIREMENTS');
expect(error.code).to.be.equal('auth/password-does-not-meet-requirements');
});
it('should map password policy server errors to the public password policy code', () => {
const error = FirebaseAuthError.fromServerError('PASSWORD_DOES_NOT_MEET_REQUIREMENTS');
expect(error.code).to.be.equal('auth/password-does-not-meet-requirements');
expect(error.message).to.be.equal('The password does not meet the requirements.');
});

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Password policy violation is reported as auth/internal-error instead of a specific error code

1 participant