fix(trogon-nats): preserve jetstream conflict detection#131
Conversation
yordis
commented
Apr 23, 2026
- keep JetStream conflict classification reusable so bucket and stream provisioning continue to treat pre-existing resources consistently.
- keep shared trait surfaces aligned with the underlying async-nats APIs so downstream code can propagate typed publish and subject-token errors without relying on concrete clients.
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
PR SummaryMedium Risk Overview Aligns the JetStream abstraction layer more closely with Improves error ergonomics by making Reviewed by Cursor Bugbot for commit 36ce78f. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 15 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe PR reorganizes JetStream publishing and conflict detection logic. It adds a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Coverage SummaryDetailsDiff against mainResults for commit: 36ce78f Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
rsworkspace/crates/trogon-nats/src/jetstream/create_conflicts.rs (1)
14-22: Implementation is correct for async-nats 0.47.0; consider defensive guards for future wrapping.The source chain works as documented:
CreateKeyValueError::with_source(BucketCreate, CreateStreamError)stores the stream error as the direct source, so one-level traversal viastd::error::Error::source()followed bydowncast_ref::<CreateStreamError>()is correct. Tests confirm this behavior.However, if async-nats ever wraps the source in an intermediate adapter type,
downcast_ref()will silently returnNoneand this function would incorrectly report "not already exists" — stopping the fallback toget_key_valuefor legitimate bucket-exists conflicts.Two optional defensive measures:
- Add a negative test asserting
falsewhenCreateKeyValueError::BucketCreatewraps aCreateStreamErrorwith a different error code (the existingTimedOuttest inlease/mod.rscovers one such case).- On async-nats upgrades, verify that
CreateKeyValueError's source chain still yieldsCreateStreamErrorat depth 1.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@rsworkspace/crates/trogon-nats/src/jetstream/traits.rs`:
- Around line 214-225: The impl for JetStreamPublishMessage on
jetstream::Context currently calls the trait-qualified
context::traits::Publisher::publish_message(self, message); change this to use
the inherent method form used elsewhere (call
jetstream::Context::publish_message(self, message) or simply
self.publish_message(message)) so the implementation matches the file's pattern
and uses the stable async-nats API; update the body of pub fn publish_message in
the impl to call the inherent method and keep the return type and error types
unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8fcb85aa-e8c4-4a86-bd16-030eb005442e
📒 Files selected for processing (8)
rsworkspace/crates/trogon-nats/src/jetstream/client.rsrsworkspace/crates/trogon-nats/src/jetstream/create_conflicts.rsrsworkspace/crates/trogon-nats/src/jetstream/mod.rsrsworkspace/crates/trogon-nats/src/jetstream/traits.rsrsworkspace/crates/trogon-nats/src/lease/mod.rsrsworkspace/crates/trogon-nats/src/lease/provision.rsrsworkspace/crates/trogon-nats/src/lease/renew.rsrsworkspace/crates/trogon-nats/src/subject_token_violation.rs
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>