Fix CLI exit codes and degraded scrape response handling#40
Merged
paulius-krutkis-dcd merged 4 commits intoJun 26, 2026
Conversation
Map plain 400/422 API errors to the documented VALIDATION exit code (4) instead of NETWORK (7), so scripts can distinguish permanent input errors from transient network failures. Detect server-side scrape failures (failed content envelopes and HTTP error statuses) and exit non-zero with the API message on stderr, instead of printing the failure body to stdout and exiting 0.
Introduced a new function, detectDegradedStatus, to identify HTTP errors that still return usable content. Updated the detectScrapeFailure function to utilize this new logic. Enhanced writeScrapeResponse to log warnings for degraded statuses. Added corresponding tests to ensure correct behavior for both functions, including scenarios where HTTP errors return valid content.
Target 5xx responses come back as a top-level { status: "failed" }
envelope with no results array. detectScrapeFailure now inspects the
response itself for that envelope before iterating, so the failure
surfaces as a ScrapeFailedError (exit 7) with the API's guidance
instead of crashing with "results is not iterable".
Both detectScrapeFailure and detectDegradedStatus now read results
through a guard, so a missing or non-array results never throws.
Pin vite to ^7.3.5 and esbuild to ^0.28.1 via pnpm overrides to clear the Dependabot advisories (vite server.fs.deny bypass and launch-editor NTLM disclosure, esbuild dev-server file read). Both are transitive dev-only deps via vitest and never ship in the CLI bundle.
ChinchillaLover9000
approved these changes
Jun 26, 2026
agnestatkeviciute92
approved these changes
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
status: "failed"envelopes, HTTP errors with no usable body) and exit 7 without writing to stdoutTest plan
status: "failed"envelope and confirm exit 7 with no stdout outputpnpm test— all tests pass