Improve input validation and error handling - #38
Conversation
Enhanced input validation to fail on non-existent or unreadable paths with clear error messages. Standardized exit codes for invalid settings or configuration files, and adjusted the positional argument name to "path" for better clarity. Updated tests and documentation to reflect these changes. (This commit message was AI-generated.) Signed-off-by: Jens Oliver Meiert <jens@meiert.com>
|
Warning Review limit reached
Next review available in: 36 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
WalkthroughThe CLI now validates input paths before processing and returns exit status ChangesInput and setup status handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Mergeability Score: 🔵 Low · up to The CLI may give misleading “missing path” errors when an input exists but cannot be accessed, so the error classification should be corrected with owner follow-up; the changelog’s August 13, 2026 release date should also be confirmed before publication. Sequence Diagram(s)sequenceDiagram
participant CLI as hihtml CLI
participant FS as Input filesystem
participant Config as config.js
participant Process as Process exit status
CLI->>FS: Check input path existence and readability
FS-->>CLI: Return path status
CLI->>Config: Load and validate configuration
Config-->>CLI: Return setupError for setup failures
CLI->>Process: Exit with status 1 for input or setup failures
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@bin/hihtml.js`:
- Around line 72-78: Update the statSync error handling around inputStats to
distinguish filesystem error codes: keep “No such file or directory” only for
ENOENT and ENOTDIR, and report “Cannot read” for EACCES access failures. Add
coverage that removes search permission from the input’s parent directory and
verifies the unreadable-input message.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 5bcb70d6-2acd-44e1-90f7-9afc359983af
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (6)
CHANGELOG.mdREADME.mdbin/hihtml.jsbin/hihtml.test.jspackage.jsonsrc/lib/config.js
Improved error handling to provide clear messages when a parent directory lacks search permissions, preventing access to an existing path. Added a corresponding test case to ensure robust handling of such scenarios. (This commit message was AI-generated.) Signed-off-by: Jens Oliver Meiert <jens@meiert.com>
Signed-off-by: Jens Oliver Meiert <jens@meiert.com>
There was a problem hiding this comment.
Pull request overview
This PR tightens CLI/setup input handling so user-fixable problems (bad paths, unreadable settings/config) are detected early and reported with clearer, consistent exit codes, while keeping runtime/checker failures distinct.
Changes:
- Added early CLI validation for input paths (existence + readability) and aligned the positional argument name to
path. - Distinguished setup/config failures from runtime failures via an error marker (
setupFailed) and exit status mapping (1vs2). - Updated tests and documentation/changelog for the new behavior and version bump to
1.6.0.
Reviewed changes
Copilot reviewed 4 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/config.js | Introduces setupError() marker and routes config/settings validation/read failures through it. |
| bin/hihtml.js | Renames positional arg to path, adds upfront input path checks, and maps setup failures to exit code 1. |
| bin/hihtml.test.js | Adds regression tests for nonexistent/unreadable inputs and for settings/setup failures exiting 1. |
| README.md | Updates CLI/report wording and exit-code documentation to reflect new behavior. |
| CHANGELOG.md | Adds 1.6.0 release notes describing input/setup failure behavior changes. |
| package.json | Bumps package version to 1.6.0. |
| package-lock.json | Updates lockfile versions to 1.6.0. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Summary by CodeRabbit
path.1for input or setup errors and2for runtime failures.0.