Skip to content

Conversation

@Chiquitulio700
Copy link

@Chiquitulio700 Chiquitulio700 commented Sep 1, 2025

🚀 Volunchain Pull Request

Mark with an x all the checkboxes that apply (like [x])

  • Closes #
  • Added tests (if necessary)
  • Run tests
  • Run formatting
  • Evidence attached
  • Commented the code

📌 Type of Change

  • Documentation (updates to README, docs, or comments)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

📝 Changes description

Create user exception

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation feedback for user-related actions. Error messages now clearly indicate which field is invalid and what value caused the issue, reducing confusion during sign-up, profile updates, and other user data submissions. This provides more precise guidance to correct mistakes and ensures a more consistent experience across the app when invalid input is detected.

@coderabbitai
Copy link

coderabbitai bot commented Sep 1, 2025

Walkthrough

Introduces a new domain exception class for the user module. The file defines InvalidUserDataException extending DomainException, with a constructor accepting field and value and formatting the message as "Invalid {field}: {value}".

Changes

Cohort / File(s) Summary of Changes
User Domain Exceptions
src/modules/user/domain/exceptions/user.exceptions.ts
Added InvalidUserDataException class extending DomainException; constructor (field: string, value: string) calls super(\Invalid ${field}: ${value}`)`. Exports the class for use in user domain validation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

I wiggle my whiskers, hop with delight,
A tidy new error now squeaks into sight.
“Invalid,” it chirps, with field and value true—
Helping our burrow know just what to do.
Thump-thump! Typed trails make bugs take flight.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 2

🧹 Nitpick comments (1)
src/modules/user/domain/exceptions/user.exceptions.ts (1)

5-5: Broaden value type or make it optional.

If you must keep it, prefer unknown (not string) to handle numbers/dates/etc. Keep it out of the message; expose only via safe metadata.

-  constructor(field: string, value: string) {
+  constructor(field: string, value?: unknown) {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 23a1f32 and 4d430a0.

📒 Files selected for processing (1)
  • src/modules/user/domain/exceptions/user.exceptions.ts (1 hunks)
🔇 Additional comments (1)
src/modules/user/domain/exceptions/user.exceptions.ts (1)

4-4: Good addition: domain-typed user exception.

Clear, scoped exception improves intent and catch specificity.

@@ -0,0 +1,8 @@
import { DomainException } from "@/modules/shared/domain/exceptions/domain.exception";
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify “@” path alias resolution in build/tests.

Ensure tsconfig paths and test runners map "@/..." correctly to avoid runtime/import failures.


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Check TS path alias mapping (@/*) in tsconfig*:"
rg -nP '"paths"\s*:\s*{[^}]*"@/\*"\s*:\s*\["src/\*"\]' tsconfig*.json -C2 || echo "Missing @ alias mapping"

echo "Check baseUrl set to src in tsconfig*:"
rg -nP '"baseUrl"\s*:\s*"src"' tsconfig*.json || echo "Missing baseUrl src"

echo "Check Jest/Vitest moduleNameMapper for @/*:"
fd -a -p -t f -E node_modules '(jest|vitest).*\.config\.(js|ts|mjs|cjs)' \
  | xargs -I{} rg -nP '@/(.*)' {} -C2 || echo "Missing moduleNameMapper for @/*"

Length of output: 860


Add missing TypeScript path alias in tsconfig.json
In tsconfig.json, set compilerOptions.baseUrl to "src" and add under compilerOptions.paths

"@/*": ["src/*"]

so that imports like @/… resolve at build time.

🤖 Prompt for AI Agents
In src/modules/user/domain/exceptions/user.exceptions.ts around line 1, imports
use the "@/..." path alias which isn't configured; update tsconfig.json by
setting compilerOptions.baseUrl to "src" and add compilerOptions.paths entry
mapping "@/*" to ["src/*"] so the "@/..." imports resolve at build time (then
restart the TS server / rebuild to pick up the change).

Comment on lines +5 to +6
constructor(field: string, value: string) {
super(`Invalid ${field}: ${value}`);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Don’t interpolate user-provided values into error messages (PII leak).

Including raw values (e.g., email, phone, token) in messages/logs is risky. Prefer generic messages and carry details as structured, non-sensitive metadata.

Apply this diff:

-export class InvalidUserDataException extends DomainException {
-  constructor(field: string, value: string) {
-    super(`Invalid ${field}: ${value}`);
-  }
-}
+export class InvalidUserDataException extends DomainException {
+  readonly code = 'USER_INVALID_DATA' as const;
+  readonly field: string;
+
+  constructor(field: string, _value?: unknown) {
+    super(`Invalid ${field}`);
+    this.name = new.target.name;
+    this.field = field;
+  }
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constructor(field: string, value: string) {
super(`Invalid ${field}: ${value}`);
export class InvalidUserDataException extends DomainException {
readonly code = 'USER_INVALID_DATA' as const;
readonly field: string;
constructor(field: string, _value?: unknown) {
super(`Invalid ${field}`);
this.name = new.target.name;
this.field = field;
}
}
🤖 Prompt for AI Agents
In src/modules/user/domain/exceptions/user.exceptions.ts around lines 5-6, the
constructor currently interpolates user-provided values into the error message
(super(`Invalid ${field}: ${value}`)); remove direct interpolation to avoid PII
leakage by using a generic message (e.g., "Invalid field value") and add
non-sensitive structured metadata on the exception instance (store field name
and, if necessary, a redacted or flagged indicator rather than the raw value) so
callers/loggers can access details without embedding raw user data in the
message.

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.

2 participants