From 472862bc5020883935109cfff42e1e87d43ea656 Mon Sep 17 00:00:00 2001 From: Hongming Wang Date: Mon, 4 May 2026 17:30:07 -0700 Subject: [PATCH] fix(external-templates): drop MOLECULE_ORG_ID from operator-facing snippets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codex / openclaw / hermes-channel snippets each instructed operators to set `MOLECULE_ORG_ID = ""`. The molecule_runtime MCP subprocess these snippets spawn never reads MOLECULE_ORG_ID — that env var is consumed only by workspace-server's TenantGuard middleware, server-side, on the tenant box itself (set by the control plane via user-data on provision). External operator → tenant calls pass TenantGuard via the isSameOriginCanvas path (Origin matches Host), with auth via Bearer token + X-Workspace-ID. The universal_mcp snippet — which calls into the same molecule_runtime — has always (correctly) omitted MOLECULE_ORG_ID; this brings codex / openclaw / hermes-channel into line. Symptom that caught it: an external codex CLI session, after pasting the codex-tab snippet, surfaced "MOLECULE_ORG_ID is still set to ''" as an unresolved blocker — agent reasonably treated the placeholder as required setup. Operator has no value to fill. Pinned with a structural test (TestExternalTemplates_NoMoleculeOrgIDPlaceholder) so the placeholder can't drift back across all six external-tab templates. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../internal/handlers/external_connection.go | 6 +-- .../handlers/external_connection_test.go | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 workspace-server/internal/handlers/external_connection_test.go diff --git a/workspace-server/internal/handlers/external_connection.go b/workspace-server/internal/handlers/external_connection.go index 847ebee6..b507e6b2 100644 --- a/workspace-server/internal/handlers/external_connection.go +++ b/workspace-server/internal/handlers/external_connection.go @@ -259,7 +259,6 @@ pip install 'git+https://github.com/Molecule-AI/hermes-channel-molecule.git' export MOLECULE_WORKSPACE_ID={{WORKSPACE_ID}} export MOLECULE_PLATFORM_URL={{PLATFORM_URL}} export MOLECULE_WORKSPACE_TOKEN="" -export MOLECULE_ORG_ID="" # 3. Edit ~/.hermes/config.yaml — under your existing top-level # gateway: block, add a plugin_platforms entry: @@ -338,7 +337,6 @@ mkdir -p ~/.codex # WORKSPACE_ID = "{{WORKSPACE_ID}}" # PLATFORM_URL = "{{PLATFORM_URL}}" # MOLECULE_WORKSPACE_TOKEN = "" -# MOLECULE_ORG_ID = "" # 3. Run codex — the molecule tools are now available to the agent: codex @@ -380,7 +378,6 @@ pip install molecule-ai-workspace-runtime # 3. Wire the molecule MCP server. {{WORKSPACE_ID}} + {{PLATFORM_URL}} # are stamped server-side; paste the auth token before running. WORKSPACE_TOKEN="" -MOLECULE_ORG_ID="" openclaw mcp set molecule "$(cat <" they can't fill, and external agents (codex CLI in +// particular) flag it as an unresolved setup blocker. +// +// The universal_mcp snippet is the reference: it calls into the same +// molecule_runtime and intentionally omits MOLECULE_ORG_ID. +func TestExternalTemplates_NoMoleculeOrgIDPlaceholder(t *testing.T) { + templates := map[string]string{ + "externalCurlTemplate": externalCurlTemplate, + "externalUniversalMcpTemplate": externalUniversalMcpTemplate, + "externalPythonTemplate": externalPythonTemplate, + "externalHermesChannelTemplate": externalHermesChannelTemplate, + "externalCodexTemplate": externalCodexTemplate, + "externalOpenClawTemplate": externalOpenClawTemplate, + } + for name, body := range templates { + if strings.Contains(body, "MOLECULE_ORG_ID") { + t.Errorf("%s contains MOLECULE_ORG_ID — operator-facing templates must not advertise this env var (TenantGuard reads it server-side from the tenant's own env, not the client)", name) + } + if strings.Contains(body, "") { + t.Errorf("%s contains \"\" placeholder — operators have no value to substitute, drop the line", name) + } + } +}