Skip to content

Conversation

@coratgerl
Copy link
Contributor

@coratgerl coratgerl commented Dec 6, 2025

Pull Request

Issue

Fixes: #9329

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)
  • Add security check
  • Add new Parse Error codes to Parse JS SDK

Summary by CodeRabbit

  • New Features

    • Added a new log-level setting signupUsernameTaken to control how sign-up failures for an already-existing username are logged (default: "info"); documentation updated.
  • Behavior

    • Sign-up failures due to duplicate usernames now respect the new log-level (including silent) without changing error responses.
  • Tests

    • Added tests verifying logging behavior for duplicate-username signups under different log-level configurations (e.g., "warn" and "silent").

✏️ Tip: You can customize this high-level summary in your review settings.

@parse-github-assistant
Copy link

🚀 Thanks for opening this pull request!

@coderabbitai
Copy link

coderabbitai bot commented Dec 6, 2025

📝 Walkthrough

Walkthrough

Adds a new log-level option signupUsernameTaken (env PARSE_SERVER_LOG_LEVELS_SIGNUP_USERNAME_TAKEN, default 'info') to LogLevels, updates error-handling middleware to honor it for Parse.Error.USERNAME_TAKEN, adds docs/types/definitions entries, and adds tests validating 'warn' and 'silent' behaviors.

Changes

Cohort / File(s) Summary
Tests
spec/ParseUser.spec.js
Adds two tests that attempt duplicate-username signups and assert logger calls for signupUsernameTaken when configured as 'warn' and 'silent', and verify the signup still throws USERNAME_TAKEN.
Options definitions & docs
src/Options/Definitions.js, src/Options/docs.js, src/Options/index.js
Introduces signupUsernameTaken in exported LogLevels with env PARSE_SERVER_LOG_LEVELS_SIGNUP_USERNAME_TAKEN, help text, and default 'info'; adds corresponding documentation and index typing/comment.
Middleware
src/middlewares.js
In handleParseErrors, reads req.config?.logLevels?.signupUsernameTaken (default 'info') and logs Parse.Error.USERNAME_TAKEN using that level; treats 'silent' as no-op and falls back to log.error if the configured level method is missing.
Type declarations
types/Options/index.d.ts
Adds signupUsernameTaken?: string to the LogLevels interface.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Pay attention to:
    • src/middlewares.js — correct default ('info'), handling of 'silent', and fallback when the logger method for the configured level is absent.
    • Consistency of env var name, help text, and default across Definitions.js, docs.js, index.js, and types/Options/index.d.ts.
    • spec/ParseUser.spec.js — ensure logger spies/assertions match the intended call counts and that the test still asserts the USERNAME_TAKEN error is raised.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive The description includes the required issue link (#9329) and indicates tests were added, but does not describe the implementation approach or changes made. Add an 'Approach' section describing how the signupUsernameTaken log level option was implemented and integrated into the codebase.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding an option to control log levels for username-taken signup failures.
Linked Issues check ✅ Passed The PR successfully implements the requested feature: adds a signupUsernameTaken log level option (defaulting to 'info') that controls logging behavior for duplicate username signup attempts, with tests validating 'warn' and 'silent' configurations.
Out of Scope Changes check ✅ Passed All changes directly support the core objective of issue #9329: adding configuration and logging for username-taken events. No unrelated modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Dec 6, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 6, 2025
@codecov
Copy link

codecov bot commented Dec 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.58%. Comparing base (6b9f896) to head (0422864).
⚠️ Report is 4 commits behind head on alpha.

Additional details and impacted files
@@           Coverage Diff           @@
##            alpha    #9962   +/-   ##
=======================================
  Coverage   92.58%   92.58%           
=======================================
  Files         191      191           
  Lines       15544    15549    +5     
  Branches      177      177           
=======================================
+ Hits        14391    14396    +5     
  Misses       1141     1141           
  Partials       12       12           

☔ View full report in Codecov by Sentry.
📢 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.

@mtrezza
Copy link
Member

mtrezza commented Dec 7, 2025

I think we can also the default level for this to info. It's not really an error or warning.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 8, 2025
Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LogEvents is still all over the code

@coratgerl
Copy link
Contributor Author

LogEvents is still all over the code

Do you mean this object ?
image

This is because in the issue you mentionned this kind of object:
image

Do you want I delete the object and pass directly the option ?

@mtrezza
Copy link
Member

mtrezza commented Dec 8, 2025

I see where you got this from. May have been a typo. logLevels does the same for Cloud Function and trigger events:

logLevels: {
  env: 'PARSE_SERVER_LOG_LEVELS',
  help: '(Optional) Overrides the log levels used internally by Parse Server to log events.',
  action: parsers.objectParser,
  type: 'LogLevels',
  default: {},
},

Let's add there, unless you can think of a reason not to? They are grouped by prefix, cloudFunction..., trigger..., so maybe add a prefix like signup... since this is a sign-up event and name it signupUsernameTaken, which is the same wording as ParseError.USERNAME_TAKEN = 202, so we have a nice mapping.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
types/Options/index.d.ts (1)

1-126: PR title suggestion in Angular convention

To align with the repo’s preferred Angular-style convention, consider updating the PR title to something like:

feat(logging): configurable log level for username-taken signups

This keeps the existing intent but adds a clear scope (logging) and a concise, action-oriented description.

Based on learnings, this helps generate a clearer changelog entry.

src/Options/index.js (1)

792-795: Clarify intended default and naming for logLevels.usernameAlreadyExists

The new option is wired and documented as:

  • Comment + :DEFAULT: say default is 'error'.
  • Type: usernameAlreadyExists: ?string;.

From the linked issue, there was discussion about:

  • Changing the default behavior to something less noisy (e.g. info), and
  • A potential name like signupUsernameTaken to align with Parse.Error.USERNAME_TAKEN.

Can you double-check that:

  1. The intended default log level for this event (for fresh installs and existing deployments) is indeed 'error', and that this matches:

    • The default in src/Options/Definitions.js for LogLevels.usernameAlreadyExists, and
    • The fallback used in the middleware when no explicit value is configured.
  2. The final option name usernameAlreadyExists is the agreed one vs. signupUsernameTaken, and if not, rename it consistently across:

    • types/Options/index.d.ts
    • src/Options/index.js
    • src/Options/Definitions.js
    • Any runtime usage (e.g. req.config.logLevels.usernameAlreadyExists in middleware, tests).

Aligning these keeps behavior, documentation, and configuration introspection in sync.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4526b0a and 5087a15.

📒 Files selected for processing (6)
  • spec/ParseUser.spec.js (1 hunks)
  • src/Options/Definitions.js (1 hunks)
  • src/Options/docs.js (1 hunks)
  • src/Options/index.js (1 hunks)
  • src/middlewares.js (2 hunks)
  • types/Options/index.d.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/middlewares.js
  • src/Options/docs.js
  • spec/ParseUser.spec.js
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.940Z
Learning: When reviewing Parse Server PRs that add new features, always check whether the feature is documented in the README.md file, though for new Parse Server options this is optional rather than required.
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-17T15:02:48.786Z
Learning: For Parse Server PRs, always suggest an Angular commit convention PR title that would make a meaningful changelog entry for developers. Update the PR title suggestion on every commit. The format should be: type(scope): description. Common types include feat, fix, perf, refactor, docs, test, chore. The scope should identify the subsystem (e.g., graphql, rest, push, security). The description should be action-oriented and clearly convey the change's impact to developers.
📚 Learning: 2025-11-08T13:46:04.940Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.940Z
Learning: For new Parse Server options, verify that the option is documented in src/Options/index.js and that npm run definitions has been executed to reflect changes in src/Options/docs.js and src/Options/Definitions.js. README.md documentation is a bonus but not required for new options.

Applied to files:

  • src/Options/Definitions.js
  • src/Options/index.js
🪛 Biome (2.1.2)
src/Options/index.js

[error] 792-792: Expected a statement but instead found '?'.

Expected a statement here.

(parse)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: PostgreSQL 15, PostGIS 3.3
  • GitHub Check: PostgreSQL 16, PostGIS 3.5
  • GitHub Check: PostgreSQL 18, PostGIS 3.6
  • GitHub Check: Node 20
  • GitHub Check: MongoDB 7, ReplicaSet
  • GitHub Check: PostgreSQL 15, PostGIS 3.4
  • GitHub Check: PostgreSQL 17, PostGIS 3.5
  • GitHub Check: MongoDB 8, ReplicaSet
  • GitHub Check: Node 22
  • GitHub Check: Redis Cache
  • GitHub Check: MongoDB 6, ReplicaSet
  • GitHub Check: PostgreSQL 15, PostGIS 3.5
  • GitHub Check: Node 18
  • GitHub Check: Docker Build
  • GitHub Check: Benchmarks
🔇 Additional comments (2)
types/Options/index.d.ts (1)

294-301: LogLevels typings for usernameAlreadyExists look consistent

usernameAlreadyExists?: string; matches the pattern of existing LogLevels properties and aligns with the new runtime option name; no typing issues here.

src/Options/Definitions.js (1)

1479-1515: Definitions entry for usernameAlreadyExists is consistent

The new module.exports.LogLevels.usernameAlreadyExists entry (env name, help text, and default: 'error') is consistent with the documentation in src/Options/index.js and with the existing LogLevels structure.

Once you confirm the intended default level and naming in src/Options/index.js, this definition will already be aligned.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 9, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 9, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 11, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/Options/Definitions.js (1)

1491-1496: Check intended default level and keep generator workflow in mind

The new signupUsernameTaken entry is syntactically and stylistically consistent, but please double‑check that default: 'error' and the help text ("Default is error.") match the intended runtime behavior for USERNAME_TAKEN and any default used in the error‑handling middleware. If you actually want this event to default to a less noisy level such as 'info', update the default and help text in src/Options/index.js and then re‑run npm run definitions so this file and src/Options/docs.js are regenerated rather than edited directly.

For the changelog, an Angular‑style PR title that fits this change could be: feat(options): add log level for signup username taken.

Based on learnings about Parse Server options and changelog conventions.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b71c7d8 and 86a0480.

📒 Files selected for processing (2)
  • src/Options/Definitions.js (1 hunks)
  • src/Options/docs.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Options/docs.js
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.940Z
Learning: When reviewing Parse Server PRs that add new features, always check whether the feature is documented in the README.md file, though for new Parse Server options this is optional rather than required.
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-17T15:02:48.786Z
Learning: For Parse Server PRs, always suggest an Angular commit convention PR title that would make a meaningful changelog entry for developers. Update the PR title suggestion on every commit. The format should be: type(scope): description. Common types include feat, fix, perf, refactor, docs, test, chore. The scope should identify the subsystem (e.g., graphql, rest, push, security). The description should be action-oriented and clearly convey the change's impact to developers.
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.940Z
Learning: For new Parse Server options, verify that the option is documented in src/Options/index.js and that npm run definitions has been executed to reflect changes in src/Options/docs.js and src/Options/Definitions.js. README.md documentation is a bonus but not required for new options.
📚 Learning: 2025-11-08T13:46:04.940Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.940Z
Learning: For new Parse Server options, verify that the option is documented in src/Options/index.js and that npm run definitions has been executed to reflect changes in src/Options/docs.js and src/Options/Definitions.js. README.md documentation is a bonus but not required for new options.

Applied to files:

  • src/Options/Definitions.js
📚 Learning: 2025-12-02T06:55:53.808Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-12-02T06:55:53.808Z
Learning: When reviewing Parse Server PRs that add or modify Parse Server options, always verify that changes are properly reflected in three files: src/Options/index.js (where changes originate), src/Options/Definitions.js, and src/Options/docs.js. The correct workflow is: make changes in index.js first, then run `npm run definitions` to automatically replicate the changes to Definitions.js and docs.js.

Applied to files:

  • src/Options/Definitions.js
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`. The preferred pattern is to create a Promise that resolves when an expected event occurs, then await that Promise.

Applied to files:

  • src/Options/Definitions.js
📚 Learning: 2025-05-09T09:59:06.289Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1340-1375
Timestamp: 2025-05-09T09:59:06.289Z
Learning: Tests in the parse-server repository should use promise-based approaches rather than callback patterns with `done()`. Use a pattern where a Promise is created that resolves when the event occurs, then await that promise.

Applied to files:

  • src/Options/Definitions.js
📚 Learning: 2025-05-04T20:41:05.147Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 9445
File: spec/ParseLiveQuery.spec.js:1312-1338
Timestamp: 2025-05-04T20:41:05.147Z
Learning: New tests in the parse-server repository should use async/await with promise-based patterns rather than callback patterns with `done()`.

Applied to files:

  • src/Options/Definitions.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: PostgreSQL 18, PostGIS 3.6
  • GitHub Check: Node 22
  • GitHub Check: PostgreSQL 15, PostGIS 3.5
  • GitHub Check: PostgreSQL 15, PostGIS 3.4
  • GitHub Check: Redis Cache
  • GitHub Check: PostgreSQL 16, PostGIS 3.5
  • GitHub Check: MongoDB 8, ReplicaSet
  • GitHub Check: Node 20
  • GitHub Check: PostgreSQL 17, PostGIS 3.5
  • GitHub Check: PostgreSQL 15, PostGIS 3.3
  • GitHub Check: MongoDB 7, ReplicaSet
  • GitHub Check: Node 18
  • GitHub Check: MongoDB 6, ReplicaSet
  • GitHub Check: Docker Build
  • GitHub Check: Code Analysis (javascript)
  • GitHub Check: Benchmarks

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you change the default to info? I think it needs to change in the definitions description as well

@coratgerl
Copy link
Contributor Author

coratgerl commented Dec 11, 2025

Yes, I fixed the option file
image

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/Options/index.js (1)

792-795: New LogLevels.signupUsernameTaken option looks good; Biome error is a Flow parse false positive

  • The new signupUsernameTaken: ?string property and its JSDoc are consistent with the existing LogLevels pattern and the PR goal; no changes needed here.
  • The Biome parse error (“Expected a statement but instead found '?'” at Line 792) is expected, because this file uses Flow type syntax (?string) and Biome is parsing it as plain JS. If Biome is part of your tooling, consider configuring it for Flow or excluding src/Options/index.js rather than changing the code.
  • Optional: since runtime behavior also treats a 'silent' value specially for this option, consider clarifying in the global log-level docs (or here) that 'silent' is accepted, not just the standard LogLevel values, so users understand how to disable this log entirely.
  • Optional meta: to better fit the Angular-style convention for changelog entries, a PR title like feat(logging): allow configuring signup username-taken log level would align with the repository style.
    Based on learnings, the new option is correctly surfaced in src/Options/index.js and src/Options/docs.js; README updates are nice-to-have but not required for new options.
src/Options/docs.js (1)

328-331: signupUsernameTaken JSDoc is correct; consider small clarity tweaks

The new @property {String} signupUsernameTaken entry accurately documents the new option and default. Optionally, you could:

  • Mention that this specifically controls logging for Parse.Error.USERNAME_TAKEN (code 202), to make the mapping explicit.
  • If you decide to document 'silent' as a valid value for log-level overrides, reference that here as well so behavior and docs fully align.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86a0480 and 0422864.

📒 Files selected for processing (3)
  • src/Options/Definitions.js (1 hunks)
  • src/Options/docs.js (1 hunks)
  • src/Options/index.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Options/Definitions.js
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.940Z
Learning: When reviewing Parse Server PRs that add new features, always check whether the feature is documented in the README.md file, though for new Parse Server options this is optional rather than required.
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-17T15:02:48.786Z
Learning: For Parse Server PRs, always suggest an Angular commit convention PR title that would make a meaningful changelog entry for developers. Update the PR title suggestion on every commit. The format should be: type(scope): description. Common types include feat, fix, perf, refactor, docs, test, chore. The scope should identify the subsystem (e.g., graphql, rest, push, security). The description should be action-oriented and clearly convey the change's impact to developers.
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.940Z
Learning: For new Parse Server options, verify that the option is documented in src/Options/index.js and that npm run definitions has been executed to reflect changes in src/Options/docs.js and src/Options/Definitions.js. README.md documentation is a bonus but not required for new options.
📚 Learning: 2025-11-08T13:46:04.940Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.940Z
Learning: For new Parse Server options, verify that the option is documented in src/Options/index.js and that npm run definitions has been executed to reflect changes in src/Options/docs.js and src/Options/Definitions.js. README.md documentation is a bonus but not required for new options.

Applied to files:

  • src/Options/index.js
🪛 Biome (2.1.2)
src/Options/index.js

[error] 792-792: Expected a statement but instead found '?'.

Expected a statement here.

(parse)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: Benchmarks
  • GitHub Check: MongoDB 8, ReplicaSet
  • GitHub Check: Node 20
  • GitHub Check: Node 18
  • GitHub Check: Redis Cache
  • GitHub Check: MongoDB 7, ReplicaSet
  • GitHub Check: MongoDB 6, ReplicaSet
  • GitHub Check: PostgreSQL 18, PostGIS 3.6
  • GitHub Check: Node 22
  • GitHub Check: PostgreSQL 15, PostGIS 3.5
  • GitHub Check: PostgreSQL 15, PostGIS 3.4
  • GitHub Check: PostgreSQL 17, PostGIS 3.5
  • GitHub Check: PostgreSQL 15, PostGIS 3.3
  • GitHub Check: PostgreSQL 16, PostGIS 3.5
  • GitHub Check: Docker Build
  • GitHub Check: Lint

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@mtrezza
Copy link
Member

mtrezza commented Dec 11, 2025

Before merging, let me check if Parse Server 9 release can be done before that.

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.

Add log option for username taken event

3 participants