Skip to content

Improve input validation and error handling - #38

Merged
j9t merged 3 commits into
mainfrom
cli-validate-input
Aug 13, 2026
Merged

j9t merged 3 commits into
mainfrom
cli-validate-input

Conversation

@j9t

@j9t j9t commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • The command-line input argument is now named path.
    • Invalid, missing, or unreadable input paths are detected before processing.
  • Bug Fixes
    • Configuration and runtime failures now return distinct exit statuses: 1 for input or setup errors and 2 for runtime failures.
    • ObsoHTML warnings remain informational and exit successfully with status 0.
  • Documentation
    • Updated the README and changelog with the revised input behavior, exit codes, and check-specific results.
  • Release
    • Version updated to 1.6.0.

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>
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@j9t, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 154e746f-9785-4be0-8e8a-e1cd59068ca3

📥 Commits

Reviewing files that changed from the base of the PR and between 10ae3e4 and 4a289c6.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • README.md
  • bin/hihtml.js
  • bin/hihtml.test.js

Walkthrough

The CLI now validates input paths before processing and returns exit status 1 for input or configuration setup failures. Configuration errors preserve their causes through setupError. Documentation and tests cover the new status behavior. The package version is 1.6.0.

Changes

Input and setup status handling

Layer / File(s) Summary
Configuration setup-error classification
src/lib/config.js
Configuration parsing, validation, and file-reading failures now use setupError and preserve underlying causes.
CLI input validation and exit statuses
bin/hihtml.js, bin/hihtml.test.js
The positional argument is named path. Missing or unreadable inputs return 1. Setup failures return 1, while runtime failures retain 2. Tests cover input, configuration, validation, link-check, and minification statuses.
Release and exit-code documentation
package.json, CHANGELOG.md, README.md
The package version is 1.6.0. The release notes and README document the updated exit statuses.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Mergeability Score: 🔵 Low · up to 10ae3

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
Loading

Possibly related PRs

  • j9t/hihtml#4: Both changes update configuration validation and CLI configuration-error handling.
  • j9t/hihtml#21: Both changes update configuration loading in src/lib/config.js.
  • j9t/hihtml#37: This change extends the same CLI input-path handling with path validation and argument renaming.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the pull request's main changes to input validation and error handling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cli-validate-input

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 313e1a6 and 10ae3e4.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • CHANGELOG.md
  • README.md
  • bin/hihtml.js
  • bin/hihtml.test.js
  • package.json
  • src/lib/config.js

Comment thread bin/hihtml.js
j9t added 2 commits August 13, 2026 00:14
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 (1 vs 2).
  • 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.

Comment thread src/lib/config.js
Comment thread CHANGELOG.md
@j9t
j9t merged commit 6572f2d into main Aug 13, 2026
7 checks passed
@j9t
j9t deleted the cli-validate-input branch August 13, 2026 07:11
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