fix(project): validate missing password files#204
Conversation
WalkthroughAdds a ChangesPassword-file validation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/commands/project.ts (1)
632-659: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win
nextActionduplicates the raw reason instead of giving actionable guidance.
passwordFileValidationErrorsetsnextAction: reason, butreasonis a low-level diagnostic string (e.g."file does not exist: /path"), already duplicated indetails.reason. Elsewhere in this codebase (ApiError.authRequired),nextActionis used for actionable guidance (e.g. "Runtestsprite setup..."), whilemessagecarries the specific problem description. Here it's inverted:messageis a generic'Invalid request.'andnextActionrestates the low-level reason — this weakens the CLI's error clarity for users hitting this path.As per path instructions,
src/**review should focus on "Correctness and clear error handling."💡 Suggested fix
function passwordFileValidationError(path: string, reason: string): ApiError { return ApiError.fromEnvelope({ error: { code: 'VALIDATION_ERROR', - message: 'Invalid request.', - nextAction: reason, + message: `Invalid --password-file: ${reason}`, + nextAction: 'Verify the file path exists and is readable, or use --password instead.', requestId: 'local', details: { field: 'password-file', path, reason }, }, }); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/commands/project.ts` around lines 632 - 659, The password file error handling in passwordFileValidationError is using nextAction for the raw diagnostic text instead of user guidance. Update passwordFileValidationError and its callers in readPasswordFile so the specific failure text is placed in the error message/details, while nextAction contains a short actionable instruction for the user (similar to ApiError.authRequired). Keep the field reference password-file and preserve the existing ENOENT/EACCES handling, but make the response clearer and more user-facing.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/commands/project.ts`:
- Around line 632-659: The password file error handling in
passwordFileValidationError is using nextAction for the raw diagnostic text
instead of user guidance. Update passwordFileValidationError and its callers in
readPasswordFile so the specific failure text is placed in the error
message/details, while nextAction contains a short actionable instruction for
the user (similar to ApiError.authRequired). Keep the field reference
password-file and preserve the existing ENOENT/EACCES handling, but make the
response clearer and more user-facing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 48c05465-e6ea-46de-9323-82a39b487b6d
📒 Files selected for processing (2)
src/commands/project.test.tssrc/commands/project.ts
Summary
Addresses the
--password-filepart of #79.testsprite project create/update --password-file <path>previously read the file directly withreadFileSync. If the file was missing or unreadable, the raw filesystem error escaped instead of the CLI's typedVALIDATION_ERRORenvelope.This PR keeps dry-run behavior unchanged, but on real create/update paths converts password-file read failures into exit 5 validation errors before any network work.
Changes
readPasswordFile()for project create/update password-file reads.VALIDATION_ERRORwithfield: "password-file".Verification
npm run format:checknpm run typechecknpx vitest run src/commands/project.test.tsnpx eslint src/commands/project.ts src/commands/project.test.tsSummary by CodeRabbit
--password-filein project create/update flows.