fix(notif): online checker false negatives#4075
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe pull request introduces a dedicated Redis connection for last-online tracking in the notification service. On the infrastructure side, a new Pulumi 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@rust/cloud-storage/notification_service/src/config.rs`:
- Around line 121-125: Add validation to require the LAST_ONLINE_REDIS_URI
configuration to be explicitly set in non-local environments, similar to the
existing SNS_APNS_VOIP_PLATFORM_ARN validation pattern shown in the code block.
Check that last_online_redis_uri (or its configuration option) is set when the
environment is not Local, and bail with an appropriate error message if it is
missing. This prevents the silent fallback to redis_uri that could cause
unintended Redis drift in non-local deployments. Apply this same validation
check at both the location shown (lines 121-125) and at the related location
mentioned (lines 130-134).
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3199a083-667f-4678-a935-f995f5b7b902
⛔ Files ignored due to path filters (1)
rust/cloud-storage/Cargo.lockis excluded by!**/*.lock,!**/Cargo.lock
📒 Files selected for processing (5)
infra/stacks/notification-service/index.tsrust/cloud-storage/notification_service/Cargo.tomlrust/cloud-storage/notification_service/src/config.rsrust/cloud-storage/notification_service/src/env.rsrust/cloud-storage/notification_service/src/main.rs
| if !matches!(config.environment, Environment::Local) | ||
| && !config.sns_apns_voip_platform_arn.is_set() | ||
| { | ||
| anyhow::bail!("SNS_APNS_VOIP_PLATFORM_ARN must be provided"); | ||
| } |
There was a problem hiding this comment.
Require LAST_ONLINE_REDIS_URI outside local to prevent silent Redis drift.
Right now, non-local startup validates SNS_APNS_VOIP_PLATFORM_ARN but not LAST_ONLINE_REDIS_URI, and last_online_redis_uri() silently falls back to redis_uri. If that env var is missing in a non-local deploy, last-online reads revert to the wrong Redis and the false-negative behavior can return.
Suggested fix
impl Config {
pub fn from_env() -> anyhow::Result<Self> {
let config = macro_config::ConfigLoader::load::<Config>()
.context("failed to load notification service config")?;
- if !matches!(config.environment, Environment::Local)
- && !config.sns_apns_voip_platform_arn.is_set()
- {
- anyhow::bail!("SNS_APNS_VOIP_PLATFORM_ARN must be provided");
+ if !matches!(config.environment, Environment::Local) {
+ if !config.sns_apns_voip_platform_arn.is_set() {
+ anyhow::bail!("SNS_APNS_VOIP_PLATFORM_ARN must be provided");
+ }
+ if !config.last_online_redis_uri.is_set() {
+ anyhow::bail!("LAST_ONLINE_REDIS_URI must be provided");
+ }
}
Ok(config)
}Also applies to: 130-134
🤖 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 `@rust/cloud-storage/notification_service/src/config.rs` around lines 121 -
125, Add validation to require the LAST_ONLINE_REDIS_URI configuration to be
explicitly set in non-local environments, similar to the existing
SNS_APNS_VOIP_PLATFORM_ARN validation pattern shown in the code block. Check
that last_online_redis_uri (or its configuration option) is set when the
environment is not Local, and bail with an appropriate error message if it is
missing. This prevents the silent fallback to redis_uri that could cause
unintended Redis drift in non-local deployments. Apply this same validation
check at both the location shown (lines 121-125) and at the related location
mentioned (lines 130-134).
6a60f4c to
83d5782
Compare
6831cf4 to
47100e7
Compare
The offline checker was reporting false negatives for last online time because it was reading from the wrong redis URL.
This pr adjusts the redis url to read from the same instance that is being written to, and moves the notification_service to use the macro_config paradigm.