refactor(errors): introduce MissingEnvVarError for missing host env vars
lint / lint (push) Failing after 1m52s
test / unit (pull_request) Failing after 40s
test / integration (pull_request) Successful in 19s

Replace die()/RuntimeError at the point of detection with a typed
MissingEnvVarError, and catch it in the CLI dispatcher alongside
ManifestError. Library code stays free of stderr output; the CLI
renders all user-facing error lines in one place.

Sites updated: egress.egress_resolve_token_values (unset/empty token),
git_gate._provision_dynamic_key and revoke_git_gate_provisioned_keys
(missing forge_token_env), env.resolve_env (unset interpolated var).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-08 12:55:30 -04:00
parent 8e89227cb8
commit a8e880fad6
5 changed files with 41 additions and 13 deletions
+7 -4
View File
@@ -23,6 +23,7 @@ from .egress_addon_core import (
PathMatch as CorePathMatch,
Route,
)
from .errors import MissingEnvVarError
from .log import die
if TYPE_CHECKING:
@@ -354,16 +355,18 @@ def egress_resolve_token_values(
for token_env, token_ref in token_env_map.items():
value = host_env.get(token_ref)
if value is None:
die(
raise MissingEnvVarError(
token_ref,
f"egress: host env var '{token_ref}' is unset. Set it "
f"before launching, or remove the corresponding auth block "
f"from bottle.egress.routes."
f"from bottle.egress.routes.",
)
if not value:
die(
raise MissingEnvVarError(
token_ref,
f"egress: host env var '{token_ref}' is empty. The "
f"egress will not inject an empty token; set it to "
f"the real value or remove the route's auth block."
f"the real value or remove the route's auth block.",
)
out[token_env] = value
return out