Skip to content

fix(NATSRS-001): CU-86akbhh82 2 review findings in message.rs - #101

Draft
flamingo[bot] wants to merge 1 commit into
mainfrom
ai-fix/natsrs-001-bdc6f2f5-cfb21c27
Draft

flamingo[bot] wants to merge 1 commit into
mainfrom
ai-fix/natsrs-001-bdc6f2f5-cfb21c27

Conversation

@flamingo

@flamingo flamingo Bot commented Aug 24, 2026

Copy link
Copy Markdown

Closes 2 review findings in async-nats/src/jetstream/message.rs.

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 🟡 72 medium Message::ack/ack_with/double_ack/info return plain std::io::Error boxed as Error instead of a typed *ErrorKind async-nats/src/jetstream/message.rs:191
2 🟡 68 medium Message::info() returns generic boxed std::io::Error variants instead of a typed InfoError/InfoErrorKind async-nats/src/jetstream/message.rs:271

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: cfb21c27-56cf-4a3e-bbfe-02ce27b8b29b

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

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

Comment on lines 228 to 242
/// # Ok(())
/// # }
/// ```
pub async fn ack(&self) -> Result<(), Error> {
pub async fn ack(&self) -> Result<(), AckError> {
if let Some(ref reply) = self.reply {
self.context
.client
.publish(reply.clone(), "".into())
.map_err(Error::from)
.map_err(|err| AckError::with_source(AckErrorKind::Other, err))
.await
} else {
Err(Box::new(std::io::Error::other(
"No reply subject, not a JetStream message",
)))
Err(AckError::new(AckErrorKind::MissingReplySubject))
}
}

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.

🦩 🔴 *Message::ack/ack_with/double_ack/info return plain std::io::Error boxed as Error instead of a typed ErrorKind

Introduced AckErrorKind/AckError (pub type AckError = error::Error<AckErrorKind>) with variants MissingReplySubject, TimedOut, Dropped, Other, implementing Display. Changed Message::ack, Message::ack_with, and Message::double_ack to return Result<(), AckError> instead of Result<(), Error>, replacing the ad-hoc Box::new(std::io::Error::other(...))/Box::new(std::io::Error::new(...)) constructions with AckError::new(...)/AckError::with_source(...). Also updated the parallel Acker::ack, Acker::ack_with, Acker::double_ack methods (same struct, same pattern) for consistency, since they share the identical ad-hoc error construction. Note: this is a public API signature change (return type changed from Error alias to AckError), which is a breaking change for callers matching on the old boxed error type, though Result<(), AckError> still coerces via ? into Result<(), Error> at call sites since AckError: std::error::Error + Send + Sync + 'static. Reviewer should confirm this breaking change is acceptable per crate versioning policy.

🤖 Prompt for AI agents
In async-nats/src/jetstream/message.rs around line 191, review and complete this code-review fix: Message::ack/ack_with/double_ack/info return plain std::io::Error boxed as Error instead of a typed *ErrorKind.
What the draft fix changed: Introduced `AckErrorKind`/`AckError` (`pub type AckError = error::Error<AckErrorKind>`) with variants `MissingReplySubject`, `TimedOut`, `Dropped`, `Other`, implementing `Display`. Changed `Message::ack`, `Message::ack_with`, and `Message::double_ack` to return `Result<(), AckError>` instead of `Result<(), Error>`, replacing the ad-hoc `Box::new(std::io::Error::other(...))`/`Box::new(std::io::Error::new(...))` constructions with `AckError::new(...)`/`AckError::with_source(...)`. Also updated the parallel `Acker::ack`, `Acker::ack_with`, `Acker::double_ack` methods (same struct, same pattern) for consistency, since they share the identical ad-hoc error construction. Note: this is a public API signature change (return type changed from `Error` alias to `AckError`), which is a breaking change for callers matching on the old boxed error type, though `Result<(), AckError>` still coerces via `?` into `Result<(), Error>` at call sites since `AckError: std::error::Error + Send + Sync + 'static`. Reviewer should confirm this breaking change is acceptable per crate versioning policy.
Verify the change is correct and complete; do not refactor unrelated code.

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

std::io::ErrorKind::TimedOut,
"double ack response timed out",
)
})? {

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.

🦩 🔴 Message::info() returns generic boxed std::io::Error variants instead of a typed InfoError/InfoErrorKind

Introduced InfoErrorKind/InfoError (pub type InfoError = error::Error<InfoErrorKind>) with variants MissingReplySubject, MissingPrefix, TooFewTokens, BadTokenNumber, ParseError, implementing Display. Changed Message::info to return Result<Info<'_>, InfoError> instead of Result<Info<'_>, Error>, replacing all Box<std::io::Error> constructions (missing reply subject, missing prefix, too few tokens, bad token number) with the corresponding typed variant, and changed the try_parse! macro's parse-failure and OffsetDateTime::from_unix_timestamp_nanos error paths to wrap the underlying parse errors via InfoError::with_source(InfoErrorKind::ParseError, ...) instead of Box::new(e)/using ? with From<time::error::ComponentRange>. This is also a breaking public API signature change; verify no other file in the crate matches on Message::info()'s old boxed-error type (only visible within this file, so cross-file impact could not be checked).

🤖 Prompt for AI agents
In async-nats/src/jetstream/message.rs around line 271, review and complete this code-review fix: Message::info() returns generic boxed std::io::Error variants instead of a typed InfoError/InfoErrorKind.
What the draft fix changed: Introduced `InfoErrorKind`/`InfoError` (`pub type InfoError = error::Error<InfoErrorKind>`) with variants `MissingReplySubject`, `MissingPrefix`, `TooFewTokens`, `BadTokenNumber`, `ParseError`, implementing `Display`. Changed `Message::info` to return `Result<Info<'_>, InfoError>` instead of `Result<Info<'_>, Error>`, replacing all `Box<std::io::Error>` constructions (missing reply subject, missing prefix, too few tokens, bad token number) with the corresponding typed variant, and changed the `try_parse!` macro's parse-failure and `OffsetDateTime::from_unix_timestamp_nanos` error paths to wrap the underlying parse errors via `InfoError::with_source(InfoErrorKind::ParseError, ...)` instead of `Box::new(e)`/using `?` with `From<time::error::ComponentRange>`. This is also a breaking public API signature change; verify no other file in the crate matches on `Message::info()`'s old boxed-error type (only visible within this file, so cross-file impact could not be checked).
Verify the change is correct and complete; do not refactor unrelated code.

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

@flamingo flamingo Bot changed the title fix(NATSRS-001): 2 review findings in message.rs fix(NATSRS-001): CU-86akbhh82 2 review findings in message.rs Sep 3, 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