Skip to content

fix(test,project): replace crashes with VALIDATION_ERROR on --since overflow and --password-file ENOENT#27

Open
crypticsaiyan wants to merge 1 commit into
TestSprite:mainfrom
crypticsaiyan:fix/validation-crashes
Open

fix(test,project): replace crashes with VALIDATION_ERROR on --since overflow and --password-file ENOENT#27
crypticsaiyan wants to merge 1 commit into
TestSprite:mainfrom
crypticsaiyan:fix/validation-crashes

Conversation

@crypticsaiyan

Copy link
Copy Markdown
Contributor

Summary

Two edge cases involving invalid user input previously caused unhandled exceptions (raw Node stack traces and exit code 1) instead of standard typed validation errors (exit code 5).

  • Bug 1: Providing an extremely large value to --since (e.g., 99999999999h) caused a RangeError: Invalid time value because it exceeded the valid JavaScript date range during .toISOString() conversion.
  • Bug 2: Providing a non-existent file path to --password-file during project creation or updates caused a raw ENOENT crash due to an unguarded readFileSync call.

The Fix

  • Date Overflow Guard: Added a Number.isFinite(result.getTime()) check in parseDuration (src/commands/test.ts) to intercept invalid dates and throw a localValidationError before attempting conversion.
  • Safe File Reading: Wrapped readFileSync calls for the password file in try/catch blocks (src/commands/project.ts) to gracefully capture read errors and emit typed validation errors.

Testing & Validation

Regression Tests Added:

  • Overflow Handling: 2 tests added to src/commands/test.result.history.spec.ts verifying that extreme --since values now trigger graceful validation errors instead of crashing.
  • File Read Handling: 2 tests added to src/commands/project.test.ts ensuring missing password files are caught during both create and update operations.

CI Gates: All local checks pass.

  • Lint & format check
  • TypeScript compiler (typecheck)
  • Unit tests
  • Coverage (≥80% threshold met)

Files Changed:

  • src/commands/test.ts
  • src/commands/project.ts
  • src/commands/test.result.history.spec.ts
  • src/commands/project.test.ts

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.

1 participant