From 336dd3f418dd175fe134b72b5a965958d23194b0 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 25 Aug 2026 03:11:29 +0000 Subject: [PATCH] fix(file-service): stop forcing share event failures Co-Authored-By: bot_apk --- services/file-service/Dockerfile | 16 ++------ services/file-service/src/config.rs | 60 +++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 13 deletions(-) diff --git a/services/file-service/Dockerfile b/services/file-service/Dockerfile index 15501b37b..376c8e1ea 100644 --- a/services/file-service/Dockerfile +++ b/services/file-service/Dockerfile @@ -27,19 +27,9 @@ USER appuser # passes false, so local stacks behave like the golden app. ENV FILE_UPLOAD_ALWAYS_FAIL=true -# Click-triggered notification failure (same bake rationale as above): sharing -# a file publishes the file_shared event to a nonexistent SNS topic, so every -# share click fails with a real AWS SNS error and fires the -# NotificationEventPublishFailure alert at admin-service (incident + Devin -# session + Slack, attributed to the sharing user via reporter_email). The -# share record is still saved, but the request returns the AWS error so the -# UI shows a red failure banner. docker-compose.yml passes false, so local -# stacks behave like the golden app. -ENV FILE_SHARE_EVENT_ALWAYS_FAIL=true - -# With uploads failing permanently (above), users would have no files to share. -# Seeding gives every user a few demo documents on their first file listing, -# so the share-notification failure is demoable alongside the upload failure. +# With uploads failing permanently (above), users would have no files to work +# with. Seeding gives every user a few demo documents on their first file +# listing, so the upload failure is demoable with existing content in place. # docker-compose.yml passes false, so local stacks behave like the golden app. ENV FILE_SEED_DEMO_DOCS=true diff --git a/services/file-service/src/config.rs b/services/file-service/src/config.rs index bb10898fd..3b90e2776 100644 --- a/services/file-service/src/config.rs +++ b/services/file-service/src/config.rs @@ -148,6 +148,66 @@ mod tests { assert!(parse_bool_env("OTTERWORKS_DEFINITELY_UNSET_ENV_VAR", true)); } + fn dockerfile_enables_share_event_failure(dockerfile: &str) -> bool { + let dockerfile = dockerfile.replace("\\\r\n", " ").replace("\\\n", " "); + + dockerfile + .lines() + .map(str::trim) + .filter_map(|line| { + let (instruction, rest) = line.split_once(char::is_whitespace)?; + instruction + .eq_ignore_ascii_case("ENV") + .then_some(rest.trim_start()) + }) + .any(|env| { + if env.contains('=') { + env.split_whitespace().any(|assignment| { + assignment + .strip_prefix("FILE_SHARE_EVENT_ALWAYS_FAIL=") + .is_some_and(|value| parse_bool(value.trim_matches(['"', '\'']), false)) + }) + } else { + env.strip_prefix("FILE_SHARE_EVENT_ALWAYS_FAIL") + .is_some_and(|value| { + value.starts_with(char::is_whitespace) + && parse_bool(value.trim().trim_matches(['"', '\'']), false) + }) + } + }) + } + + #[test] + fn image_does_not_force_share_event_failures() { + assert!(!dockerfile_enables_share_event_failure(include_str!( + "../Dockerfile" + ))); + } + + #[test] + fn share_event_failure_detection_handles_env_syntax_variants() { + for line in [ + "ENV FILE_SHARE_EVENT_ALWAYS_FAIL=true", + "env FILE_SHARE_EVENT_ALWAYS_FAIL=1", + "ENV FILE_SHARE_EVENT_ALWAYS_FAIL true", + "ENV FILE_SHARE_EVENT_ALWAYS_FAIL=\"true\"", + "ENV FILE_UPLOAD_ALWAYS_FAIL=true FILE_SHARE_EVENT_ALWAYS_FAIL=true", + "ENV FILE_UPLOAD_ALWAYS_FAIL=true \\\n FILE_SHARE_EVENT_ALWAYS_FAIL=true", + ] { + assert!(dockerfile_enables_share_event_failure(line), "line={line}"); + } + + for line in [ + "ENV FILE_SHARE_EVENT_ALWAYS_FAIL=false", + "ENV FILE_SHARE_EVENT_ALWAYS_FAIL false", + "ENV FILE_SHARE_EVENT_ALWAYS_FAIL_OTHER=true", + "ENV FILE_UPLOAD_ALWAYS_FAIL=true", + "# ENV FILE_SHARE_EVENT_ALWAYS_FAIL=true", + ] { + assert!(!dockerfile_enables_share_event_failure(line), "line={line}"); + } + } + #[test] fn upload_always_fail_is_off_by_default() { if std::env::var("FILE_UPLOAD_ALWAYS_FAIL").is_ok() {