Skip to content

Map HTTP 404 to NotFoundError (README example never matched) - #33

Merged
jochen-testingbot merged 1 commit into
masterfrom
fix/map-404-not-found
Nov 10, 2026
Merged

jochen-testingbot merged 1 commit into
masterfrom
fix/map-404-not-found

Conversation

@jochen-testingbot

Copy link
Copy Markdown
Contributor

Part of https://testingbot-team.atlassian.net/browse/TB-1008 (docs audit: run every SDK README snippet).

README walkthrough result (npm 1.2.0, node:22-bookworm-slim)

37 of 38 README calls work against the live API: browsers, devices, IP ranges, user, tests (all getTests forms), test details, tunnels, builds, uploadRemoteFile/getStorageFile/deleteStorageFile of the sample APK, storage list, share hash, screenshots, team, codeless list, getAllTests, getTestStatistics, batchGetTestDetails, and the CLI commands user info, tests list, browsers list, devices list|available, config ip-ranges, tunnel list, team info, storage list, lab list and --version.
The one failure was getTests({ ..., build: 'ci-42' }), which 404s only because that build doesn't exist in my account. It is expected.

Bug fixed here

The Error Handling section imports NotFoundError from the package, and the class is exported and typed in index.d.ts, but nothing ever threw it:

await tb.getTestDetails('does-not-exist')
-> error.name 'TestingBotError', statusCode 404, error instanceof NotFoundError === false

buildHttpError now maps 404 to NotFoundError, keeping the server message, statusCode and response. It still extends TestingBotError, so existing catch code keeps working. The README table and example now include 404.

Verification

npm run lint                                   -> clean
npx mocha --grep "Typed errors|Parameter validation|Request shaping|Workflow helpers"  -> 58 passing
README error-handling example against the live API:
  No such test -> NotFoundError 404 404 Not Found. Could not find test does-not-exist true

Release needed for npm (1.2.1). That is needs-jochen.

NotFoundError is exported, typed in index.d.ts and imported in the README's
error-handling example, but buildHttpError never produced it: a 404 came
back as a plain TestingBotError, so 'instanceof NotFoundError' was always
false. Map 404 to NotFoundError (still a TestingBotError, so existing
catch blocks keep working), add a unit test and document it.

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.

🟢 Approved

The review records no active issues, with the 404 mapping, preserved response details, tests, and documentation covering the change.

No open issues 🎉

What changed in this PR

Updates HTTP error handling so HTTP 404 responses produce the exported NotFoundError, while preserving the original message, status code, and response data.

Changes:

  • Map HTTP 404 responses to NotFoundError.
  • Add tests covering error type, inheritance, status, message, and response preservation.
  • Document 404 handling in the README error example and status table.

This pull request requires changes.

File Summary
test/​errors.test.js Verifies the new 404 error mapping and preserved response data.
README.md Documents NotFoundError handling for missing resources.
lib/​http-error.js Maps 404 responses to NotFoundError; the constructed error currently uses placeholder resource/id metadata that should be made meaningful.

Review effort: Lite

@jochen-testingbot
jochen-testingbot merged commit 3db1d8b into master Nov 10, 2026
6 checks passed
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