Skip to content

fix(resources): return 404 for nonexistent resource ID#2462

Open
dirkwa wants to merge 1 commit intoSignalK:masterfrom
dirkwa:fix-resource-not-found
Open

fix(resources): return 404 for nonexistent resource ID#2462
dirkwa wants to merge 1 commit intoSignalK:masterfrom
dirkwa:fix-resource-not-found

Conversation

@dirkwa
Copy link
Contributor

@dirkwa dirkwa commented Mar 17, 2026

Description:

getResource() returned {} instead of an error when a resource ID didn't exist, making it impossible for callers to distinguish "not found" from a valid empty resource.

The getFromAll() helper used Promise.allSettled and silently ignored all rejections, always returning the initial {}. Now throws when no provider returns data, so HTTP endpoints return 404 and the programmatic API (app.resourcesApi.getResource()) rejects the promise.

Manually tested

  • GET /signalk/v2/api/resources/waypoints/nonexistent-id → 404 {"state":"FAILED","statusCode":404,"message":"Resource not found! (nonexistent-id)"}
  • GET /signalk/v2/api/resources/waypoints/ → 200 {} (empty collection, unaffected)

Fixes #1612

getFromAll() returned {} when no provider had the requested resource,
making it impossible to distinguish a missing resource from a valid
empty one. Now throws so HTTP endpoints return 404 and the
programmatic API rejects the promise.

Fixes SignalK#1612
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.

Request for nonexistent resource returns {} rather than an exception

1 participant