Skip to content

fix(fastify-rdf): return 400 for malformed JSON-LD body#194

Merged
ddeboer merged 1 commit intomainfrom
fix/json-ld-parse-error-status-code
Mar 4, 2026
Merged

fix(fastify-rdf): return 400 for malformed JSON-LD body#194
ddeboer merged 1 commit intomainfrom
fix/json-ld-parse-error-status-code

Conversation

@ddeboer
Copy link
Member

@ddeboer ddeboer commented Mar 4, 2026

Summary

When a request with Content-Type: application/ld+json contains malformed JSON, the content type parser's JSON.parse throws a SyntaxError. This error was passed to Fastify via done(err) without setting statusCode, so Fastify defaulted to 500.

  • Set statusCode = 400 on the SyntaxError before passing it to Fastify's done() callback
  • Add test for malformed JSON-LD body returning 400

Fix #191

- Set statusCode = 400 on SyntaxError before passing to Fastify's
  done() callback; without it Fastify defaults to 500
- Add test for malformed JSON-LD returning 400
@ddeboer ddeboer enabled auto-merge (squash) March 4, 2026 10:46
@ddeboer ddeboer merged commit ff1c868 into main Mar 4, 2026
2 checks passed
@ddeboer ddeboer deleted the fix/json-ld-parse-error-status-code branch March 4, 2026 10:47
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.

Content type parser JSON.parse errors return 500 instead of 400

1 participant