Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/modules/user/domain/exceptions/user.exceptions.ts
Original file line number Diff line number Diff line change
@@ -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).



export class InvalidUserDataException extends DomainException {
constructor(field: string, value: string) {
super(`Invalid ${field}: ${value}`);
Comment on lines +5 to +6
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.

}
}