Skip to content

fix: Incorrect TypeScript type for passwordPolicy validatorCallback option#10528

Open
dblythy wants to merge 1 commit into
parse-community:alphafrom
dblythy:fix/password-policy-validator-callback-type
Open

fix: Incorrect TypeScript type for passwordPolicy validatorCallback option#10528
dblythy wants to merge 1 commit into
parse-community:alphafrom
dblythy:fix/password-policy-validator-callback-type

Conversation

@dblythy

@dblythy dblythy commented Jul 4, 2026

Copy link
Copy Markdown
Member

Issue

Closes #10471

Approach

Corrects the TypeScript type of the passwordPolicy.validatorCallback option from () => void to (password: string) => boolean, matching how it is actually invoked at runtime (src/RestWrite.js) and used in the specs. Previously, a correctly-typed (password: string) => boolean callback produced a compile error.

Tasks

  • Add tests

Summary by CodeRabbit

  • Bug Fixes
    • Updated password policy validation to use a password input and return a true/false result, making the expected behavior clearer and more consistent.
  • Tests
    • Added type coverage to ensure valid password validators are accepted and invalid return types are rejected.

@parse-github-assistant

Copy link
Copy Markdown

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5e68e62a-21a8-4405-af1c-f17f98995b95

📥 Commits

Reviewing files that changed from the base of the PR and between 7e9d53a and 0a2f965.

📒 Files selected for processing (3)
  • src/Options/index.js
  • types/Options/index.d.ts
  • types/tests.ts

📝 Walkthrough

Walkthrough

The validatorCallback option in PasswordPolicyOptions is retyped from a no-argument () => void callback to (password: string) => boolean, updated consistently in the JS options source and TypeScript declaration file, with new type tests validating correct and incorrect usages.

Changes

validatorCallback typing fix

Layer / File(s) Summary
Update callback signature
src/Options/index.js, types/Options/index.d.ts
validatorCallback changed from () => void to (password: string) => boolean in both the JS options definition and TypeScript declarations.
Add type tests
types/tests.ts
New $ExpectType and $ExpectError assertions validate that validatorCallback accepting a password and returning boolean is accepted, and one returning string is rejected.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Related issues: #10471 (Typing issue with passwordPolicy validatorCallback)

Suggested labels: type-definitions, bug

Suggested reviewers: mtrezza

🐰

A callback once returned nothing at all,
Now it judges passwords, standing tall.
A string comes in, a boolean comes out,
Type tests confirm without a doubt.
Small fix, big relief for TypeScript folk! 🔐

🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Engage In Review Feedback ❓ Inconclusive Review-feedback engagement isn’t recorded in the repo; I can only verify the final type/test change, not any discussion or response to comments. Provide PR review-thread evidence showing comments were discussed and then either implemented in a commit or retracted by the reviewer.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the PR's main change: fixing the TypeScript type for passwordPolicy.validatorCallback.
Description check ✅ Passed The description includes the issue, approach, and tests, but it omits some template boilerplate and optional task items.
Linked Issues check ✅ Passed The PR updates the callback type and adds type tests, satisfying issue #10471's requirement for correct password-aware boolean typing.
Out of Scope Changes check ✅ Passed The changes are limited to the validatorCallback type definitions and matching tests, with no unrelated scope added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Security Check ✅ Passed Only type/test updates; runtime already calls validatorCallback(password) and expects a boolean, so no new security risk appears.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Biome (2.5.1)
src/Options/index.js

File contains syntax errors that prevent linting: Line 18: Expected a type but instead found '?'.; Line 18: Expected a property, or a signature but instead found ';'.; Line 21: Expected a statement but instead found '?'.; Line 24: Expected a statement but instead found '?'.; Line 27: Expected a statement but instead found '?'.; Line 30: Expected a statement but instead found '?'.; Line 32: Expected a statement but instead found '?'.; Line 34: Expected a statement but instead found '?'.; Line 35: Expected a statement but instead found '}'.; Line 37: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 38: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 39: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 40: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Li

... [truncated 16757 characters] ...

found '?'.; Line 912: Expected a statement but instead found '?'.; Line 914: Expected a statement but instead found '?'.; Line 915: Expected a statement but instead found '}'.; Line 929: Expected a type but instead found '?'.; Line 929: Expected a property, or a signature but instead found ';'.; Line 930: Expected a statement but instead found '}'.; Line 936: Expected a type but instead found '?'.; Line 936: Expected a property, or a signature but instead found ';'.; Line 940: Expected a statement but instead found '?'.; Line 944: Expected a statement but instead found '?'.; Line 948: Expected a statement but instead found '?'.; Line 952: Expected a statement but instead found '?'.; Line 956: Expected a statement but instead found '?'.; Line 957: Expected a statement but instead found '}'.


Comment @coderabbitai help to get the list of available commands.

@dblythy dblythy requested a review from mtrezza July 4, 2026 14:03
@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.66%. Comparing base (cce91e5) to head (0a2f965).
⚠️ Report is 1 commits behind head on alpha.

Additional details and impacted files
@@           Coverage Diff           @@
##            alpha   #10528   +/-   ##
=======================================
  Coverage   92.66%   92.66%           
=======================================
  Files         193      193           
  Lines       16981    16981           
  Branches      248      248           
=======================================
  Hits        15736    15736           
  Misses       1224     1224           
  Partials       21       21           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dblythy dblythy requested a review from a team July 5, 2026 01:42
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.

Typing Issue with passwordPolicy validatorCallback

1 participant