Skip to content

Conversation

@RAprogramm
Copy link
Owner

Summary

  • add an RFC7807 ProblemJson module with metadata sanitization and code mappings
  • update Axum and Actix adapters to emit problem+json bodies and share response helpers
  • implement the optional tonic conversion from Error to tonic::Status and expand documentation/tests

Testing

  • cargo +nightly fmt --
  • cargo +nightly build --all-targets
  • cargo +nightly test --all
  • cargo +nightly test --all --features tonic
  • cargo +nightly clippy -- -D warnings
  • cargo +nightly doc --no-deps
  • cargo audit
  • cargo deny check

https://chatgpt.com/codex/tasks/task_e_68d22c305394832b9cd6886a76268463

@RAprogramm RAprogramm merged commit 326135e into new_version Sep 23, 2025
1 of 2 checks passed
@RAprogramm RAprogramm deleted the codex/create-problem_json-module-with-serialization branch September 23, 2025 08:23
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines +25 to +35
let mut builder = HttpResponse::build(status);
builder.insert_header((CONTENT_TYPE, "application/problem+json"));

if let Some(retry) = retry_after {
builder.insert_header((RETRY_AFTER, retry.to_string()));
}
if let Some(challenge) = www_authenticate {
builder.insert_header((WWW_AUTHENTICATE, challenge));
}

builder.json(problem)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Preserve problem+json Content-Type in Actix responses

The Actix responder sets Content-Type: application/problem+json before calling builder.json(problem), but HttpResponseBuilder::json rewrites the header to application/json. As a result all RFC7807 responses are sent with the wrong media type even though the module claims to emit application/problem+json. Move the header assignment after builder.json or serialize manually so the final response retains the problem+json content type.

Useful? React with 👍 / 👎.

Comment on lines +225 to +242
pub fn from_error_response(response: ErrorResponse) -> Self {
let mapping = mapping_for_code(response.code);
let detail = if response.message.is_empty() {
None
} else {
Some(Cow::Owned(response.message))
};

Self {
type_uri: Some(mapping.problem_type()),
title: Cow::Owned(mapping.kind().to_string()),
status: response.status,
detail,
code: response.code,
grpc: Some(mapping.grpc()),
metadata: None,
retry_after: response.retry.map(|value| value.after_seconds),
www_authenticate: response.www_authenticate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Converting ErrorResponse to ProblemJson drops details payload

ProblemJson::from_error_response ignores ErrorResponse::details entirely, yet IntoResponse for ErrorResponse now funnels every response through this conversion. Any structured or textual details attached via with_details* no longer reach clients, which is a behavioral regression for existing users of ErrorResponse. Consider mapping details into an extension field (e.g. metadata) or keep details in the serialized payload so the original contract is preserved.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants