Skip to content

Classify serde_json errors for AppError mapping#12

Merged
RAprogramm merged 1 commit intomainfrom
codex/implement-error-classification-in-apperror
Sep 11, 2025
Merged

Classify serde_json errors for AppError mapping#12
RAprogramm merged 1 commit intomainfrom
codex/implement-error-classification-in-apperror

Conversation

@RAprogramm
Copy link
Owner

Summary

  • classify serde_json errors into serialization or deserialization using serde_json::error::Category
  • document the new mapping logic
  • test IO and syntax error classifications

Testing

  • cargo build --all-targets --features serde_json
  • cargo clippy --all-targets --features serde_json -- -D warnings
  • cargo test --all --features serde_json
  • cargo doc --no-deps --features serde_json

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

@RAprogramm RAprogramm merged commit b1b18a7 into main Sep 11, 2025
1 of 2 checks passed
@RAprogramm RAprogramm deleted the codex/implement-error-classification-in-apperror branch September 11, 2025 07:00
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.

fn from(err: SjError) -> Self {
match err.classify() {
Category::Io => AppError::serialization(err.to_string()),
Category::Syntax | Category::Data | Category::Eof => {
AppError::deserialization(err.to_string())
}

[P1] Avoid misclassifying deserialize I/O failures as serialization errors

The new From<serde_json::Error> implementation maps every Category::Io to AppError::serialization, but serde_json::Error::classify() does not encode whether the error happened while encoding or decoding. When serde_json::from_reader fails because the underlying Read returns an io::Error (e.g., a client disconnects mid‑request), err.classify() is also Io, so this code will report a serialization error even though the failure occurred during deserialization. Because Category::Io (and Category::Data) is used for both encode and decode paths, relying on it alone yields incorrect error kinds and misleads callers that inspect AppErrorKind. Consider preserving the previous Internal mapping or letting the caller decide the context instead of forcing all I/O errors into Serialization.


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".

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.

1 participant