fix: guard resolve_profile_env against missing profile dirs

The _default_spawn HERMES_HOME injection (PR #23356) calls
resolve_profile_env which raises FileNotFoundError when the profile
dir doesn't exist. In production the profile always exists (workers are
only dispatched for live profiles), but tests with isolated HERMES_HOME
never create profile dirs. Catch FileNotFoundError and fall through —
HERMES_PROFILE is still set below, so the worker CLI resolves the
profile at startup.
This commit is contained in:
kshitijk4poor 2026-05-11 18:44:15 +05:30 committed by kshitij
parent 7087702210
commit 5712483487

View file

@ -3941,7 +3941,14 @@ def _default_spawn(
# profile-specific config entirely. Fixes profile-scoped fallback_providers
# being invisible to kanban workers.
from hermes_cli.profiles import resolve_profile_env
env["HERMES_HOME"] = resolve_profile_env(profile_arg)
try:
env["HERMES_HOME"] = resolve_profile_env(profile_arg)
except FileNotFoundError:
# Profile dir doesn't exist — defer resolution to the CLI's
# _apply_profile_override() via HERMES_PROFILE (set below).
# This only happens in test fixtures where the isolated
# HERMES_HOME never had profiles created.
pass
if task.tenant:
env["HERMES_TENANT"] = task.tenant
env["HERMES_KANBAN_TASK"] = task.id