acoustic-carpenter-78188
08/02/2026, 11:23 PMflyte.map(...) and flyte.map.aio(...) yielded bare, un-awaited coroutines instead of task results.
Both local branches in _Mapper.__call__ / _Mapper.aio did yield func(*v). For an async task inside a run context, func(*v) returns the un-awaited LocalController.submit(...) coroutine, so callers got coroutine objects (with RuntimeWarning: coroutine 'LocalController.submit' was never awaited) and task exceptions never surfaced, silently breaking return_exceptions semantics too.
Fix
• New _invoke_local(func, arg_tuple) helper in `src/flyte/_map.py`: partial-aware (mirrors MapAsyncIterator._invoke), awaits func.aio(...), and additionally awaits the forward() coroutine for the no-task-context case (async task mapped outside any run).
• _Mapper.aio local branch: yield await _invoke_local(func, v) — stays on the caller's loop.
• _Mapper.__call__ local branch: yield _invoke_local_sync(func, v) (syncified) — bridges into the syncify background loop, the same mechanism the remote branch already uses via `_map(...)`; contextvars propagate through run_coroutine_threadsafe, so the child still submits through the LocalController (tracking/cache preserved).
Tests
tests/flyte/test_map_local.py (all previously red on main except the sync-task case, which only worked because a sync function returns its value directly):
• flyte.map.aio over an async task in a local run yields awaited results
• blocking flyte.map over an async task in a local run yields awaited results
• blocking flyte.map over a sync task (regression guard for the one path that already worked)
• return_exceptions=True yields the exception instance, not a coroutine
Each test asserts not inspect.iscoroutine(r) per item plus final output values.
Verified: repro from #1359 now prints `['echo:a', 'echo:b', 'echo:c']`; ruff + mypy clean on changed files; broad tests/flyte sweep passes (2548 passed; only pre-existing environment-dependent failures in `keyring`/`test_int_image_builder`, which fail identically on clean main).
🤖 Generated with Claude Code
flyteorg/flyte-sdkacoustic-carpenter-78188
08/03/2026, 5:57 PM