feat(trogon-gateway): require webhook integrations#156
Conversation
PR SummaryMedium Risk Overview Namespaces all webhook routes under Docker Compose/dev docs are updated to mount Reviewed by Cursor Bugbot for commit 3e244d5. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ 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 refactors trogon-gateway from single-config-per-source to multi-instance webhook routing. A new ChangesMulti-Instance Webhook Routing Refactor
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
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: 3e244d5 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
devops/docker/compose/services/trogon-gateway/README.md (1)
47-70: ⚡ Quick winConsider adding guidance for persistent TOML config setup.
The
docker compose runexample is helpful for testing, but users deploying multi-webhook configurations permanently would need to mount the volume incompose.ymlrather than passing it on the command line. Consider adding a brief note about adding the volume and command args to the gateway service definition incompose.ymlfor persistent deployments.📝 Example addition
After line 70, you could add:
For persistent deployment, add the volume mount and config flag to the `trogon-gateway` service in `compose.yml`: ```yaml services: trogon-gateway: volumes: - ./gateway.toml:/etc/trogon-gateway/gateway.toml:ro command: ["--config", "/etc/trogon-gateway/gateway.toml"]</details> <details> <summary>🤖 Prompt for AI Agents</summary>Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.In
@devops/docker/compose/services/trogon-gateway/README.mdaround lines 47 -
70, Add a short persistent-deployment note to the README explaining how to mount
the TOML and pass the config flag in the Docker Compose service definition
(referencing the trogon-gateway service in compose.yml); instruct users to add a
volumes entry that mounts ./gateway.toml to /etc/trogon-gateway/gateway.toml:ro
and add the command/args ["--config", "/etc/trogon-gateway/gateway.toml"] (or
equivalent) to the trogon-gateway service so the gateway uses the persistent
config rather than the transient docker compose run example.</details> </blockquote></details> </blockquote></details> <details> <summary>🤖 Prompt for all review comments with AI agents</summary>Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.Nitpick comments:
In@devops/docker/compose/services/trogon-gateway/README.md:
- Around line 47-70: Add a short persistent-deployment note to the README
explaining how to mount the TOML and pass the config flag in the Docker Compose
service definition (referencing the trogon-gateway service in compose.yml);
instruct users to add a volumes entry that mounts ./gateway.toml to
/etc/trogon-gateway/gateway.toml:ro and add the command/args ["--config",
"/etc/trogon-gateway/gateway.toml"] (or equivalent) to the trogon-gateway
service so the gateway uses the persistent config rather than the transient
docker compose run example.</details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Organization UI **Review profile**: CHILL **Plan**: Pro **Run ID**: `b084951d-bf2c-42cc-9234-2e07a091ed1d` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between aec1a447e2ef270773028a7f67d986d558624067 and 4dd79720766c5402c1e215260d7cf2e0b541c538. </details> <details> <summary>📒 Files selected for processing (9)</summary> * `devops/docker/compose/.env.example` * `devops/docker/compose/compose.yml` * `devops/docker/compose/services/trogon-gateway/README.md` * `rsworkspace/crates/trogon-gateway/README.md` * `rsworkspace/crates/trogon-gateway/src/config.rs` * `rsworkspace/crates/trogon-gateway/src/http.rs` * `rsworkspace/crates/trogon-gateway/src/main.rs` * `rsworkspace/crates/trogon-gateway/src/source_instance_id.rs` * `rsworkspace/crates/trogon-gateway/src/streams.rs` </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
4dd7972 to
3bc2b71
Compare
3bc2b71 to
b300f74
Compare
b300f74 to
88c0da5
Compare
cc92fe6 to
55791d6
Compare
55791d6 to
32e3bb1
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 32e3bb1. Configure here.
66575cd to
757edb5
Compare
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
757edb5 to
25ceff3
Compare
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
rsworkspace/crates/trogon-gateway/src/source_integration_id.rs (1)
14-19: 💤 Low valueConsider clarifying the relationship between
MAX_INTEGRATION_ID_LENandNatsToken's length limit.The code checks
char_count > MAX_INTEGRATION_ID_LENbefore callingNatsToken::new, which also validates length. IfMAX_INTEGRATION_ID_LENmatchesNatsToken's internal limit, the early check is redundant (though harmless). If they differ, a brief comment explaining whySourceIntegrationIdenforces a stricter limit would improve clarity.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rsworkspace/crates/trogon-gateway/src/source_integration_id.rs` around lines 14 - 19, The length-check against MAX_INTEGRATION_ID_LEN before calling NatsToken::new is ambiguous—either remove the redundant char_count > MAX_INTEGRATION_ID_LEN check if MAX_INTEGRATION_ID_LEN is identical to NatsToken's internal max, or if SourceIntegrationId intentionally enforces a stricter limit, add a concise comment above the check explaining the relationship (e.g., "SourceIntegrationId enforces a stricter length than NatsToken to X") and keep the existing error return (SourceIntegrationIdError::TooLong), leaving the NatsToken::new(...).map_err(SourceIntegrationIdError::from_subject_token_violation)? call as the secondary validation.rsworkspace/crates/trogon-gateway/src/streams.rs (1)
7-90: ⚖️ Poor tradeoffConsider extracting the integration provisioning pattern into a helper function.
Lines 7-90 repeat the same pattern for each webhook source: iterate integrations, provision, log with source + integration. A helper function could reduce duplication:
async fn provision_integrations<C, T, F>( client: &C, source: &'static str, integrations: &[SourceIntegration<T>], provision_fn: F, ) -> Result<(), C::Error> where C: JetStreamContext, F: Fn(&C, &T) -> impl std::future::Future<Output = Result<(), C::Error>>, { for integration in integrations { provision_fn(client, &integration.config).await?; info!( source, integration = integration.id.as_str(), "stream provisioned" ); } Ok(()) }However, given the straightforward nature and limited scope, the current explicit approach is acceptable.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rsworkspace/crates/trogon-gateway/src/streams.rs` around lines 7 - 90, The code repeats the same iterate->call provision->log pattern for each source (e.g., config.github, config.slack, crate::source::github::provision, info! logging), so extract a generic async helper (e.g., provision_integrations) that accepts the JetStream client, a &'static str source name, a slice of integrations (like &[SourceIntegration<T>]) and a provision function (Fn(&C, &T) -> Future<Output=Result<() ,C::Error>>), then replace each duplicated loop (for integration in &config.github / &config.slack / etc.) with a call to that helper passing the appropriate crate::source::<x>::provision function and source name so provisioning and the info!(source, integration = integration.id.as_str(), "stream provisioned") logging are centralized.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rsworkspace/crates/trogon-gateway/src/main.rs`:
- Around line 97-108: The startup currently propagates Telegram webhook
registration errors (via the `?` after `registration_http_client()` and
`register_webhook(...)`), which contradicts the README; change the behavior so
registration failures are non-blocking by catching errors instead of using `?`:
obtain the HTTP client with a fallible call but handle its Err by logging and
continuing, and for each config call
`crate::source::telegram::registration::register_webhook(config,
&telegram_http_client).await` inside a match or `if let
Err(e)`/`.await.unwrap_or_else(|e| { log/error!(...) })`-style block so failures
are logged and do not return early; keep using the existing
`telegram_registration_configs` collection and the
`crate::source::telegram::registration::registration_http_client()` /
`register_webhook` symbols to locate the code.
---
Nitpick comments:
In `@rsworkspace/crates/trogon-gateway/src/source_integration_id.rs`:
- Around line 14-19: The length-check against MAX_INTEGRATION_ID_LEN before
calling NatsToken::new is ambiguous—either remove the redundant char_count >
MAX_INTEGRATION_ID_LEN check if MAX_INTEGRATION_ID_LEN is identical to
NatsToken's internal max, or if SourceIntegrationId intentionally enforces a
stricter limit, add a concise comment above the check explaining the
relationship (e.g., "SourceIntegrationId enforces a stricter length than
NatsToken to X") and keep the existing error return
(SourceIntegrationIdError::TooLong), leaving the
NatsToken::new(...).map_err(SourceIntegrationIdError::from_subject_token_violation)?
call as the secondary validation.
In `@rsworkspace/crates/trogon-gateway/src/streams.rs`:
- Around line 7-90: The code repeats the same iterate->call provision->log
pattern for each source (e.g., config.github, config.slack,
crate::source::github::provision, info! logging), so extract a generic async
helper (e.g., provision_integrations) that accepts the JetStream client, a
&'static str source name, a slice of integrations (like &[SourceIntegration<T>])
and a provision function (Fn(&C, &T) -> Future<Output=Result<() ,C::Error>>),
then replace each duplicated loop (for integration in &config.github /
&config.slack / etc.) with a call to that helper passing the appropriate
crate::source::<x>::provision function and source name so provisioning and the
info!(source, integration = integration.id.as_str(), "stream provisioned")
logging are centralized.
🪄 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: cb7552d1-d4ee-4349-9705-ef541a2addd5
📒 Files selected for processing (13)
devops/docker/compose/.env.exampledevops/docker/compose/compose.ymldevops/docker/compose/services/trogon-gateway/README.mdrsworkspace/crates/trogon-gateway/README.mdrsworkspace/crates/trogon-gateway/src/config.rsrsworkspace/crates/trogon-gateway/src/constants.rsrsworkspace/crates/trogon-gateway/src/http.rsrsworkspace/crates/trogon-gateway/src/main.rsrsworkspace/crates/trogon-gateway/src/source/telegram/config.rsrsworkspace/crates/trogon-gateway/src/source/telegram/registration.rsrsworkspace/crates/trogon-gateway/src/source_integration_id.rsrsworkspace/crates/trogon-gateway/src/streams.rsservices/trogon-gateway/gateway.toml
✅ Files skipped from review due to trivial changes (2)
- rsworkspace/crates/trogon-gateway/src/constants.rs
- rsworkspace/crates/trogon-gateway/src/source/telegram/registration.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- rsworkspace/crates/trogon-gateway/src/source/telegram/config.rs
- devops/docker/compose/compose.yml
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>

Uh oh!
There was an error while loading. Please reload this page.