Skip to content

fix: map 404 responses to NotFoundError in REST and Bridge transports#147

Open
1HazyOne707 wants to merge 2 commits into
neo4j-labs:mainfrom
1HazyOne707:fix/not-found-error-on-404
Open

fix: map 404 responses to NotFoundError in REST and Bridge transports#147
1HazyOne707 wants to merge 2 commits into
neo4j-labs:mainfrom
1HazyOne707:fix/not-found-error-on-404

Conversation

@1HazyOne707

Copy link
Copy Markdown

Problem

getEntity() throws TransportError instead of NotFoundError when an entity does not exist. This breaks typed catch blocks:

try {
  await memory.longTerm.getEntity("ent-00000000-0000-0000-0000-000000000000");
} catch (e) {
  console.log(e instanceof NotFoundError);  // false — wrong
  console.log(e instanceof TransportError); // true  — wrong
}

Root cause

Both RestTransport and BridgeTransport map all non-OK HTTP responses to TransportError, including 404s.

Fix

Add a response.status === 404 check before the generic error path in both transports and throw NotFoundError with the same message. Added NotFoundError import to both files.

Closes #125

Both RestTransport and BridgeTransport mapped all non-OK HTTP responses
to TransportError, including 404s. This broke typed catch blocks that
handle missing entities — getEntity() on a non-existent ID would throw
TransportError instead of NotFoundError.

Fix: check response.status === 404 before the generic error path and
throw NotFoundError with the same message. Added NotFoundError import
to both transport files.

Closes neo4j-labs#125
@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

@1HazyOne707 is attempting to deploy a commit to the lyonwj's projects Team on Vercel.

A member of the Team first needs to authorize it.

@1HazyOne707

Copy link
Copy Markdown
Author

Hey @lyonwj — could you authorize the Vercel preview when you get a chance? Thanks!

@1HazyOne707

Copy link
Copy Markdown
Author

Hey @lyonwj — just checking in on #147, #148, and #149 whenever you get a chance. Happy to make any adjustments needed. Thanks!

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.

[TypeScript SDK] getEntity throws TransportError instead of NotFoundError for missing entities

1 participant