flyte icon indicating copy to clipboard operation
flyte copied to clipboard

[BUG] [v2] `Trigger(env_vars=...)` are recorded in the trigger spec but never reach the task pod

Open earlybard opened this issue 4 months ago • 2 comments

Describe the bug

Env vars declared on a trigger — flyte.Trigger(..., env_vars={...}) — are serialized into the deployed trigger's run_spec.envs, but runs fired by the trigger do not receive them: the pod never sees the variables.

Task-spec env vars (TaskEnvironment(env_vars=...)) are not affected — they land in container.env and are present in the pod for both client-launched and trigger-fired runs.

This contradicts the documented behavior. The Trigger docstring (flyte/_trigger.py) says:

:param env_vars: Environment variables for triggered runs (overrides the task's configured values).

and the triggers user guide lists env_vars as a supported Trigger parameter with a worked example.

Steps to reproduce

import os
import flyte

env = flyte.TaskEnvironment("envdump", env_vars={"FROM_TASK_SPEC": "1"})


@env.task(
    triggers=flyte.Trigger(
        "envdump-minutely", automation=flyte.Cron("* * * * *"), env_vars={"FROM_TRIGGER": "1"}
    )
)
async def dump() -> str:
    return repr({k: v for k, v in os.environ.items() if k.startswith("FROM_")})


flyte.deploy(env)
  1. Deploy: the returned trigger spec contains run_spec.envs = {FROM_TRIGGER: "1"}.
  2. Wait for the trigger to fire. The run's output is {'FROM_TASK_SPEC': '1'} — FROM_TRIGGER is missing.

Expected behavior

Runs fired by a trigger have the trigger's env_vars set in the pod, overriding task-spec vars per key (consistent with client-injected run-level envs).

Environment

  • flyte SDK 2.5.9 (Python 3.14), self-hosted Flyte v2 backend

Related

The ModuleNotFoundError failures on trigger-fired runs of src/-layout projects are a separate bug: flyte deploy never records _F_SYS_PATH (see flyte-sys-path-deploy-bug-report.md). Because trigger env vars are dropped, a trigger can't be used to patch that gap either — but TaskEnvironment(env_vars={"_F_SYS_PATH": ...}) works.

earlybard avatar Jul 20 '26 04:07 earlybard

It seems likely that this is a real bug: Trigger(env_vars=...) values are serialized into the trigger's run_spec.envs, but are not propagated to the task pod at runtime. The documentation and examples indicate that env_vars on a Trigger should override or supplement those from TaskEnvironment, but only the latter are present in the pod's environment for triggered runs, not the former. This contradicts both the Trigger docstring and the user guide, which show env_vars as a supported and effective parameter.

Tests and code confirm that env_vars on a Trigger are included in the serialized trigger spec (run_spec.envs), but there is no evidence in the data sources that these are actually injected into the pod at execution time for triggered runs. Task-level env vars (TaskEnvironment(env_vars=...)) do work as expected. This suggests a backend or runtime bug where trigger-level env vars are ignored or dropped when constructing the pod spec for triggered executions. Would you like a step-by-step breakdown of where this disconnect likely occurs in the code and how to further debug or patch it?

Sources:


This is an AI-generated response and your feedback is appreciated! Please leave a 👍 if this is helpful and 👎 if it is not.

Mention @herald to ask follow-up questions. See runllm.com for more!

runllm avatar Jul 20 '26 04:07 runllm

Thanks for reporting this. Seems like it is really a bug.

popojk avatar Jul 21 '26 02:07 popojk