Skip to content

fix(NATSRS-002): CU-86akbhh82 info() constructs io::Error and Box<dyn Error> instead of the crate's Error<Kind> pattern - #135

Draft
flamingo[bot] wants to merge 1 commit into
mainfrom
ai-fix/natsrs-002-3f220866-4fa2224e
Draft

flamingo[bot] wants to merge 1 commit into
mainfrom
ai-fix/natsrs-002-3f220866-4fa2224e

Conversation

@flamingo

@flamingo flamingo Bot commented Sep 14, 2026

Copy link
Copy Markdown

Closes findings from rule NATSRS-002 — info() constructs io::Error and Box instead of the crate's Error pattern.

Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.

# Fix confidence Finding Location
1 🟡 75 medium info() constructs io::Error and Box instead of the crate's Error pattern async-nats/src/jetstream/message.rs:293

What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.


Run: https://product-hub.flamingo.so/admin/code-review
Run id: 4fa2224e-8528-443d-a51a-823c78308977

Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.

ClickUp task: CU-86akbhh82 NATS async-nats and CI review findings (9 PRs)

@flamingo flamingo Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 What this fix changed, finding by finding

1 finding(s) fixed in this draft — 1 explained inline on the diff.

InfoError::new(InfoErrorKind::MissingReplySubject)
})?;

if !reply.starts_with(PREFIX) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🔴 info() constructs io::Error and Box instead of the crate's Error pattern

Introduced a dedicated InfoErrorKind enum (MissingReplySubject, MissingPrefix, TooFewTokens, ParseError, BadTokenNumber) and its InfoError = error::Error<InfoErrorKind> type alias, following the same pattern as StreamMessageErrorKind/StreamMessageError defined earlier in the file. In Message::info() (async-nats/src/jetstream/message.rs), replaced all std::io::Error/Box::new(std::io::Error::other(...)) constructions with InfoError::new(...) / InfoError::with_source(...) for the missing-reply-subject check, missing-prefix check, the try_parse! macro's too-few-tokens and parse-error branches, and the final bad-token-number branch. The function signature Result<Info<'_>, Error> is unchanged since InfoError boxes into Error via the existing From impl used elsewhere in the crate (as seen with StreamMessageError usage patterns). Left the unrelated ack/ack_with/double_ack/Acker io::Error usages untouched since the finding only targeted info(). Risk: I could not see the exact error::Error::new/with_source signatures beyond their use with StreamMessageErrorKind, so I mirrored that call convention exactly; if Error::new requires different arity this won't compile, but the pattern used is identical to the one already proven in this same file.

🤖 Prompt for AI agents
In async-nats/src/jetstream/message.rs around line 293, review and complete this code-review fix: info() constructs io::Error and Box<dyn Error> instead of the crate's Error<Kind> pattern.
What the draft fix changed: Introduced a dedicated `InfoErrorKind` enum (MissingReplySubject, MissingPrefix, TooFewTokens, ParseError, BadTokenNumber) and its `InfoError = error::Error<InfoErrorKind>` type alias, following the same pattern as `StreamMessageErrorKind`/`StreamMessageError` defined earlier in the file. In `Message::info()` (async-nats/src/jetstream/message.rs), replaced all `std::io::Error`/`Box::new(std::io::Error::other(...))` constructions with `InfoError::new(...)` / `InfoError::with_source(...)` for the missing-reply-subject check, missing-prefix check, the `try_parse!` macro's too-few-tokens and parse-error branches, and the final bad-token-number branch. The function signature `Result<Info<'_>, Error>` is unchanged since `InfoError` boxes into `Error` via the existing `From` impl used elsewhere in the crate (as seen with `StreamMessageError` usage patterns). Left the unrelated `ack`/`ack_with`/`double_ack`/`Acker` io::Error usages untouched since the finding only targeted `info()`. Risk: I could not see the exact `error::Error::new`/`with_source` signatures beyond their use with `StreamMessageErrorKind`, so I mirrored that call convention exactly; if `Error::new` requires different arity this won't compile, but the pattern used is identical to the one already proven in this same file.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 75 medium — react 👍/👎 to teach the reviewer

@flamingo flamingo Bot changed the title fix(NATSRS-002): info() constructs io::Error and Box<dyn Error> instead of the crate's Error<Kind> pattern fix(NATSRS-002): CU-86akbhh82 info() constructs io::Error and Box<dyn Error> instead of the crate's Error<Kind> pattern Sep 14, 2026
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.

0 participants