file-service: fix NoSuchBucket upload failures (FileUploadHighErrorRate) - #1543
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…t at startup The upload handler consulted a Redis chaos flag and, when set, swapped the S3 client onto a hard-coded nonexistent bucket, so uploads failed with NoSuchBucket regardless of S3_BUCKET. Remove the redirect and the Redis wiring that existed only for it, and add a HeadBucket check at boot so a misconfigured bucket is logged before the first upload fails.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Devin Review found 1 potential issue.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| s3.upload_object(&s3_key, file_bytes.freeze(), &content_type) | ||
| .await?; |
There was a problem hiding this comment.
🟡 File-upload chaos injection becomes inert
After upload_file stops reading the Redis flag, the supported file-upload-fails scenario leaves uploads healthy. Both inject-bug.sh and ChaosController still set that flag and report success.
Prompt for agents
Restore the file-upload-fails lab contract without making Redis a production boot dependency. The current change removes all consumers of chaos:file-service:upload_s3_error, while scripts/inject-bug.sh, scripts/bug-catalog.yaml, the admin-service ChaosController, the admin dashboard, runbook, and alerting configuration still expose that scenario as functional. Keep the planted failure available in the golden app, preferably through an optional or lazily established Redis connection so unavailable Redis does not block startup. Alternatively, if repository owners intentionally retire the scenario, remove every control and catalog entry atomically so callers cannot receive false success.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Confirmed, and intentional for this incident fix: the chaos:file-service:upload_s3_error redirect is the root cause of FileUploadHighErrorRate, so file-upload-fails (inject-bug.sh / bug-catalog.yaml / admin ChaosController) becomes a no-op for any tenant running this build. Whether that scenario should stay a lab fixture on main is an owner decision (flagged in the PR description); if the answer is "keep it", the alternative is to leave this on a workshop/variant branch rather than re-adding the fault to the upload path.
Summary
Incident:
FileUploadHighErrorRate— >10% ofPOST /api/v1/files/uploadreturning 5xx withNoSuchBucket.Root cause: the failure is not in
S3_BUCKET/ Terraform.upload_fileinservices/file-service/src/handlers.rsbuilt a throwawayS3Clientper request and, whenever the Redis keychaos:file-service:upload_s3_errorexisted, silently swapped the bucket to a hard-codedotterworks-files-chaos-nonexistent:Every other S3 call (download, presign, delete, copy) used the configured bucket, which is why only uploads failed while the configured bucket (
terraform output s3_file_bucket→otterworks-files-<env>) was correct. The Redis key is set byscripts/inject-bug.sh <tenant> file-upload-fails(scripts/bug-catalog.yaml).Fix:
upload_filenow uses the sharedS3Client(configuredS3_BUCKET) unconditionally; the per-request bucket override is gone.rediscrate from file-service — it existed only for this flag and made Redis a hard boot dependency of a service that otherwise never uses it (REDIS_HOST/REDIS_PORTenv vars set by the deploy scripts are now ignored; left in place to keep this change scoped).S3Client::verify_bucket()(HeadBucketat startup) so a genuinely misconfigured bucket name is logged as anerrorwith the bucket name at boot, rather than first surfacing as request 500s.Note for maintainers: this removes the
file-upload-failschaos scenario frombug-catalog.yamlfor any tenant deployed from this branch. PerAGENTS.md(planted bugs are lab fixtures onmain), decide whether this should merge tomainor be kept on a workshop/variant branch.cargo clippy --all-targetsclean,cargo test11/11 passing.Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/3db5fbeff77f4befb570377d959800e3
Open in Devin Desktop: https://partner-workshops.devinenterprise.com/desktop/session/3db5fbeff77f4befb570377d959800e3?variant=devin