Commit 660805a
fix: accept list of triggers/links in @env.task decorator (#1037)
## Summary
`@env.task(triggers=[trigger, ...])` previously surfaced as
`DeploymentError: ... 'list' object has no attribute 'env_vars'` at
deploy time. The decorator's coercion in `_task_environment.py` only
checked for `tuple`, so a list was wrapped into a 1-tuple containing the
list — and the inner list leaked through to `to_task_trigger`, which
tried to read `.env_vars` off it.
The user-facing docstring at `_trigger.py:724` uses
`triggers=[my_trigger]` (list syntax), so users routinely hit this.
## Changes
- `src/flyte/_task_environment.py:369-370` — coerce triggers by element
type (`isinstance(triggers, Trigger)`) and links by container type
(`Link` is a non-runtime-checkable Protocol, so we check for
list/tuple). Both now correctly handle a single object, a list, or a
tuple.
- `tests/user_api/test_triggers.py` — added
`test_task_with_triggers_as_list` and
`test_task_with_single_element_list_trigger` covering the regression.
## Sentry
Closes the deploy-time failure tracked in
[FLYTE-SDK-17](https://unionai.sentry.io/share/issue/20054cd7e859428193c471b057c9a032/).
## Test plan
- [x] `pytest tests/user_api/test_triggers.py` — 32 passed (30 existing
+ 2 new)
- [x] `pytest tests/user_api/test_task_environment.py
tests/user_api/test_triggers.py tests/flyte/test_trigger.py
tests/flyte/internal/runtime/test_trigger_serde.py` — 93 passed
- [ ] Manual: deploy a task with `triggers=[t1, t2]` against a real
backend (no longer raises)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 1370d86 commit 660805a
2 files changed
Lines changed: 35 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
369 | | - | |
370 | | - | |
| 369 | + | |
| 370 | + | |
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
183 | 216 | | |
184 | 217 | | |
185 | 218 | | |
| |||
0 commit comments