Skip to content

Return errors for missing infe content types - #218

Draft
kixelated wants to merge 1 commit into
mainfrom
codex/issue-179-infe
Draft

Return errors for missing infe content types#218
kixelated wants to merge 1 commit into
mainfrom
codex/issue-179-infe

Conversation

@kixelated

Copy link
Copy Markdown
Owner

Split from #199. Refs #179.

What changed

  • Return Error::MissingContent when encoding a version 0 infe entry without its required content type.
  • Return the same error for mime entries without a content type.
  • Avoid cloning optional strings while encoding.
  • Add regression tests for both invalid encoder states.

Why

These required fields were unwrapped during encoding, so invalid caller-provided state could panic instead of returning a normal error.

Impact

Encoding malformed infe entries now fails predictably without changing valid output.

Validation

  • cargo fmt --all -- --check
  • cargo test --all-features (252 unit tests and 3 doctests passed)
  • cargo clippy --all-targets --all-features -- -D warnings
  • git diff --check main...HEAD

Comment thread src/meta/iinf.rs
.as_str()
.encode(buf)?;
let content_type = self.content_type.as_deref().ok_or(Error::MissingContent(
"content_type required for infe version 0",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"content_type required for infe version 0",
"content_type required for infe version 0 or 1",

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.

2 participants