aws_batch_tags / METAFLOW_BATCH_DEFAULT_TAGS silently ignored unless METAFLOW_BATCH_EMIT_TAGS=true
Tags set via @batch(aws_batch_tags={"CostCenter": "123"}) or the METAFLOW_BATCH_DEFAULT_TAGS environment variable are silently dropped when METAFLOW_BATCH_EMIT_TAGS is not set. No warning or error is raised.
In enterprise deployments this is more than cosmetic: many organizations enforce mandatory tagging policies via AWS Service Control Policies (SCPs) or AWS Config rules. When required tags (e.g. CostCenter, Team, Environment) are absent, AWS rejects the resource operation entirely, causing the Batch job submission to fail with an access-denied error that gives no hint the root cause is a Metaflow configuration flag.
Metaflow version: master, 4871fb1
Deployment: AWS Batch
METAFLOW_BATCH_EMIT_TAGS: not set (default False)
Steps to reproduce
- Set
@batch(aws_batch_tags={"CostCenter": "123"})(orMETAFLOW_BATCH_DEFAULT_TAGS='{"CostCenter": "123"}') - Do not set
METAFLOW_BATCH_EMIT_TAGS - Run the flow
Without a mandatory tagging SCP: job submits but has no tags — silent data loss. With a mandatory tagging SCP: job submission is rejected by AWS with an access-denied or tag-policy-violation error, making the flow completely unusable even though the user has correctly configured the required tags.
Expected
Tags explicitly provided by the user are applied to the job regardless of METAFLOW_BATCH_EMIT_TAGS. That flag is meant to control Metaflow's own internal observability tags (app=metaflow, metaflow.flow_name, etc.), not whether operator-defined cost-attribution or compliance tags take effect.
Actual
The aws_batch_tags block sits inside the if BATCH_EMIT_TAGS: guard in batch.py (L380–L403) (introduced in 6c7766a). User-defined tags share the guard with Metaflow's internal metadata tags even though their purpose — and the consequences of omitting them — are entirely different.
Source: Netflix/metaflow