fix(builtin_tools/temporal_workflow): collapse dead if/else in _platform_url()
All checks were successful
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 27s
audit-force-merge / audit (pull_request) Has been skipped
sop-tier-check / tier-check (pull_request) Successful in 10s

RC 835 (infra-lead): the if/else that checked for Docker and set the
PLATFORM_URL default had both branches return the same value. Collapsed
to a single return statement with a docstring explaining why the legacy
non-Docker branch is removed.

This completes Path B: all 6 PLATFORM_URL sites in this PR now have
clean, non-dead default logic.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Molecule AI · infra-runtime-be 2026-05-11 07:40:08 +00:00
parent 151b6021fb
commit bed7966f9d

View File

@ -56,17 +56,15 @@ logger = logging.getLogger(__name__)
def _platform_url() -> str:
"""Return the platform URL, defaulting to host.docker.internal when running
inside a Docker container (where localhost refers to the container, not the
host). External callers can always override via the PLATFORM_URL env var.
"""Return the platform URL, defaulting to host.docker.internal.
Note: both branches now use the same default the platform API is only
reachable via host.docker.internal from within a workspace container,
regardless of how the container was started. The if/else structure is
preserved for future extensibility.
The workspace runtime always runs inside a Docker container, so
``localhost`` refers to the container itself, not the platform host.
The platform API is only reachable via ``host.docker.internal`` from
within a workspace container, regardless of how the container was started.
The legacy non-Docker branch is removed (it would have returned
``localhost:8080`` which is unreachable from inside the container).
"""
if os.path.exists("/.dockerenv") or os.environ.get("DOCKER_VERSION"):
return os.environ.get("PLATFORM_URL", "http://host.docker.internal:8080")
return os.environ.get("PLATFORM_URL", "http://host.docker.internal:8080")
# ─────────────────────────────────────────────────────────────────────────────