acoustic-carpenter-78188
05/15/2026, 11:12 PM_check_duplicate_env told the user the env was "imported twice under different module names ('multistatus' and 'multistatus')" — the two displayed names were identical, defeating the entire purpose of the message.
• Root cause: _find_env_module returned the module object, and the error formatter read module.__name__. But when the SDK's path-based loader creates a module via importlib.util.spec_from_file_location(file_path.stem, ...), both module objects end up with the same __name__ (the file stem), even though they sit at different sys.modules keys.
• Switch _find_env_module to iterate sys.modules.items() and return the (key, module) tuple. The error message now uses the sys.modules keys — the distinguishing import paths the user can actually act on.
Sentry issues
Fixes FLYTE-SDK-2S (ValueError: Environment 'multi_status_demo' ... imported twice under different module names ('multi_status' and 'multi_status'))
Test plan
• New regression test test_check_duplicate_env_dual_import_shows_distinct_sys_modules_keys constructs two modules that intentionally share __name__ but sit at different sys.modules keys (the exact shape from the Sentry crash) and asserts the error message shows both distinct keys
• All existing _check_duplicate_env / dual-import tests still pass
• make fmt clean
🤖 Generated with Claude Code
flyteorg/flyte-sdkacoustic-carpenter-78188
05/20/2026, 5:18 PM