Skip to content

fix(api): return 415 for missing/incorrect content type - #211

Merged
Manuel1234477 merged 1 commit into
StellarGateLabs:mainfrom
Markodiba:feature/132-json-body-415-content-type
Jul 29, 2026
Merged

fix(api): return 415 for missing/incorrect content type#211
Manuel1234477 merged 1 commit into
StellarGateLabs:mainfrom
Markodiba:feature/132-json-body-415-content-type

Conversation

@Markodiba

Copy link
Copy Markdown
Contributor

Summary

JsonBody's FromRequest impl mapped JsonRejection::MissingJsonContentType to a generic 400, so clients sending the wrong Content-Type couldn't distinguish it from other body-validation errors. This now returns a 415 with a dedicated unsupported_media_type code.

Closes #132

Validation performed

  • rustfmt --check on the changed file (clean for the lines touched)
  • Note: cargo check/clippy currently fail repo-wide due to a pre-existing unrelated syntax error in src/api/mod.rs (rate_limit_middleware, unclosed let limited = { ... } block) present on main before this change — not touched here, out of scope for this issue.

Closes StellarGateLabs#132

JsonBody previously mapped MissingJsonContentType to a generic 400,
making wrong content-type requests indistinguishable from other body
errors. Now returns 415 with code unsupported_media_type.
@Manuel1234477
Manuel1234477 merged commit 6a129ff into StellarGateLabs:main Jul 29, 2026
1 of 5 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.

AppError 415/content-type handling is limited to the JSON extractor

3 participants