fix: add FLAIR2_ prefix to all ECS environment variable names#66
fix: add FLAIR2_ prefix to all ECS environment variable names#660b00101111 merged 1 commit intomainfrom
Conversation
app/config.py uses env_prefix="FLAIR2_", so all env vars injected by ECS must carry the prefix to be picked up by pydantic-settings: REDIS_URL → FLAIR2_REDIS_URL S3_BUCKET → FLAIR2_S3_BUCKET ENV → FLAIR2_ENVIRONMENT Without this fix the containers would start but settings.redis_url, settings.s3_bucket, and settings.environment would all fall back to their defaults (empty string / "dev"), silently misconfiguring the app. Applies to both API and Celery worker task definitions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates ECS task definition environment variable names to match the backend’s pydantic-settings configuration (env_prefix="FLAIR2_"), preventing silent fallback to default settings at runtime.
Changes:
- Renames non-secret ECS container environment variables to include the
FLAIR2_prefix for both the API and worker task definitions. - Aligns the environment variable used for
settings.environmenttoFLAIR2_ENVIRONMENT.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| environment = [ | ||
| { name = "REDIS_URL", value = var.redis_url }, | ||
| { name = "S3_BUCKET", value = var.s3_bucket_name }, | ||
| { name = "ENV", value = var.env } | ||
| { name = "FLAIR2_REDIS_URL", value = var.redis_url }, | ||
| { name = "FLAIR2_S3_BUCKET", value = var.s3_bucket_name }, | ||
| { name = "FLAIR2_ENVIRONMENT", value = var.env } | ||
| ] |
There was a problem hiding this comment.
The PR description says these are consumed via settings.redis_url / settings.s3_bucket, but the current backend Settings model (backend/app/config.py) does not define redis_url or s3_bucket, and a repo-wide search shows no other usage. Either add those settings fields in the backend (so these env vars actually take effect) or update the PR description / remove these env vars to avoid misleading configuration drift.
| environment = [ | ||
| { name = "REDIS_URL", value = var.redis_url }, | ||
| { name = "S3_BUCKET", value = var.s3_bucket_name }, | ||
| { name = "ENV", value = var.env } | ||
| { name = "FLAIR2_REDIS_URL", value = var.redis_url }, | ||
| { name = "FLAIR2_S3_BUCKET", value = var.s3_bucket_name }, | ||
| { name = "FLAIR2_ENVIRONMENT", value = var.env } | ||
| ] |
There was a problem hiding this comment.
Same as API task definition: the repo’s backend config currently has no Settings.redis_url / Settings.s3_bucket fields and there are no code references to these values. If the worker is expected to consume them, add the settings fields (or otherwise ensure the application reads FLAIR2_REDIS_URL / FLAIR2_S3_BUCKET) or update the PR description to match current behavior.
Problem
Same class of bug as PR #64 —
app/config.pyusesenv_prefix="FLAIR2_", so pydantic-settings only reads vars that carry the prefix. The three non-secret env vars in both ECS task definitions were missing it:ENVFLAIR2_ENVIRONMENTsettings.environmentREDIS_URLFLAIR2_REDIS_URLsettings.redis_url(M3)S3_BUCKETFLAIR2_S3_BUCKETsettings.s3_bucket(M3)Without this fix the containers would start without crashing, but
settings.environmentwould silently stay"dev"regardless of the tfvar, and the Redis/S3 fields added in M3 would always fall back to empty string.Changes
terraform/modules/ecs/main.tf— rename env vars in both API and Celery worker task definitions (6 lines)Test plan
terraform validatepasses (CI)terraform apply: confirm env vars visible in ECS console → task definition → container → environment