Skip to content

fix: add FLAIR2_ prefix to all ECS environment variable names#66

Merged
0b00101111 merged 1 commit intomainfrom
fix/ecs-env-var-prefix
Mar 28, 2026
Merged

fix: add FLAIR2_ prefix to all ECS environment variable names#66
0b00101111 merged 1 commit intomainfrom
fix/ecs-env-var-prefix

Conversation

@tyrahappy
Copy link
Copy Markdown
Collaborator

Problem

Same class of bug as PR #64app/config.py uses env_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:

Before After Config field
ENV FLAIR2_ENVIRONMENT settings.environment
REDIS_URL FLAIR2_REDIS_URL settings.redis_url (M3)
S3_BUCKET FLAIR2_S3_BUCKET settings.s3_bucket (M3)

Without this fix the containers would start without crashing, but settings.environment would 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 validate passes (CI)
  • After terraform apply: confirm env vars visible in ECS console → task definition → container → environment

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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.environment to FLAIR2_ENVIRONMENT.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 56 to 60
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 }
]
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 146 to 150
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 }
]
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@0b00101111 0b00101111 merged commit 837d853 into main Mar 28, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants