fix(cloud): export runWithTrajectoryPurpose + fetchWithSsrfGuard from Worker core-stub — unblock prod deploy - #12870
NubsCarson wants to merge 1 commit into
Conversation
…more) from Worker core-stub — unblock prod deploy The 'Deploy to Cloudflare Workers' step on main (run 28680305905, promote PR #12051 carrying the money fixes) fails at the wrangler esbuild bundle: No matching export in "src/stubs/elizaos-core.ts" for import "runWithTrajectoryPurpose" ../../shared/src/email-classification/email-classifier.ts:20 No matching export in "src/stubs/elizaos-core.ts" for import "fetchWithSsrfGuard" ../../../plugins/plugin-elizacloud/src/models/transcription.ts:2 Same Worker-stub-drift class as #11845/#11857/#11865/#11875/#11902: commit c7b4c1d ("clear monetization branch blockers", a stale branch merged after the hotfixes) deleted the runWithTrajectoryPurpose export that #11845/#11875 added, and the transcription audioUrl SSRF guard import was never stubbed. A local production dry-run additionally surfaced 8 more missing stub exports that accumulated on develop while the wrangler step was masked by the earlier build:core failure (registerSubscriptionAuthProvider / getSubscriptionAuthProvider / hasSubscriptionAuthProvider, isSensitiveKeyName / redactLogArgs, CLOUD_AUTH_SERVICE_TYPE, setAnthropicAccountPoolBridge / setCodingAgentSelectorBridge). Fixes, matching the stub's existing patterns: - runWithTrajectoryPurpose: pass-through beside runWithTrajectoryContext (trajectory manager lives on the agent sidecar; observability-only). - fetchWithSsrfGuard: Worker-safe port of core's guard reusing the REAL pure ssrf.ts validators (no drift in the blocklist) — per-hop http/https + private-IP/hostname checks, manual redirects with re-validation, WHATWG GET-rewrite, cross-origin credential stripping, fail-closed lookupFn-without-pinnedFetchImpl. SSRF protection is NOT weakened; only the Node-only auto pinned-DNS transport is omitted (workerd has no node:dns), exactly core's documented EDGE-SSRF mode. - isSensitiveKeyName/redactLogArgs re-exported from core's pure redact module (real redaction — a no-op would leak secrets into Worker logs). - subscription-auth registry + account-pool bridges re-exported from their pure core modules (one shared instance in the bundle). - CLOUD_AUTH_SERVICE_TYPE mirrored (ServiceType.CLOUD_AUTH). Verified: bunx wrangler deploy --env production --dry-run → exit 0, zero errors, Total Upload 15967.15 KiB / gzip 3544.10 KiB; package typecheck clean; stub tests extended (9 pass) incl. SSRF block/redirect/ credential-strip behavior. NOTE: the develop deploy lane has a SECOND independent blocker (build:core fails: core src/cloud-routing.ts TS2307 @elizaos/cloud-routing) that this PR does not address. [cloud-security]
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Closing as superseded by current develop: #12807/#12823 already restored the Worker core-stub exports this PR adds, including runWithTrajectoryPurpose, fetchWithSsrfGuard, subscription auth helpers, redaction helpers, CLOUD_AUTH_SERVICE_TYPE, and the account-pool bridge setters. I verified current origin/develop exports those symbols and ran the focused stub test: |
URGENT — prod deploy blocker (maintainer review requested, do not let it sit)
Unblocks the promote #12051 prod deploy carrying the money fixes (#12047 embeddings affiliate, #11976/#11989, #11785). Please review + merge via maintainer lane — I am not self-merging.
The break (deploy run 28680305905, job 85062716654, re-run failed identically 2026-07-04T04:2x)
Deploy to Cloudflare Workers/ wrangler esbuild fails onmain(and would fail on develop once itsbuild:coreblocker is cleared):Worker-stub-drift, same class as #11845/#11857/#11865/#11875/#11902. Root cause of the first: commit
c7b4c1d332("fix: clear monetization branch blockers" — a stale branch merged after the hotfixes) deleted therunWithTrajectoryPurposeexport that #11845/#11875 had added. The second: plugin-elizacloud's transcriptionaudioUrlfetch was routed through the SSRF guard (correctly), but the guard was never stubbed for the Worker bundle.A local production dry-run surfaced 8 more missing stub exports that accumulated while the wrangler step was masked by the develop lane's earlier
build:corefailure — all fixed here too:registerSubscriptionAuthProvider/getSubscriptionAuthProvider/hasSubscriptionAuthProvider(packages/auth),isSensitiveKeyName/redactLogArgs(cloud-shared logger),CLOUD_AUTH_SERVICE_TYPE(plugin-elizacloud cloud-auth),setAnthropicAccountPoolBridge/setCodingAgentSelectorBridge(app-core services).What was added (matches the stub's existing patterns)
runWithTrajectoryPurpose— pass-through beside the existingrunWithTrajectoryContextstand-in. The trajectory context manager lives on the agent sidecar; purpose-tagging is observability, nothing billing/security-bearing runs through it in the Worker.fetchWithSsrfGuard— Worker-safe port of core's guard that reuses the real, purecore/src/network/ssrf.tsvalidators (zero imports, zero I/O) so the blocklist (exotic IPv4 encodings, IPv6 prefixes, metadata hostnames) cannot drift. Full contract preserved: http/https-only per hop, private/loopback/link-local + internal-hostname blocking honoringpolicy, manual redirects re-validated every hop, WHATWG 301/302-POST/303 GET-rewrite + body-header strip, cross-origin credential stripping, timeout/abort, and fail-closed onlookupFnwithoutpinnedFetchImpl. The only delta from core is omitting the Node-autoloaded pinned-DNS transport — workerd has nonode:dns; this is exactly core's own documented EDGE-SSRF mode. SSRF protection is not weakened. (Bonus: bundling core's real guard would have been wrong on workerd —nodejs_compatdefinesprocess.versions.node, so core would try the Node pinned transport and fail closed at runtime.)isSensitiveKeyName/redactLogArgs— re-exported from core's puresecurity/redact.ts. These must stay real: a no-op here would leak API keys/tokens into Worker logs.@elizaos/coreimport resolves to this stub, so the bundle shares one registry instance).CLOUD_AUTH_SERVICE_TYPE— mirrored (ServiceType.CLOUD_AUTH, same value as core).Build proof (real output, local dry-run of the exact wrangler build the deploy runs)
Before the fix, the identical local harness reproduced the missing-export failures (the 2 from CI + the 8 newly-exposed ones), so the harness demonstrably catches this error class.
Also verified:
bun run --cwd packages/cloud/api typecheck→ cleanbunx biome checkon both files → cleanbun test __tests__/elizaos-core-stub.test.ts→ 9 pass — new tests cover the SSRF guard for real: private-IP/metadata/localhost blocking before any fetch, non-http(s) rejection, fail-closed lookupFn-without-pinned-transport, redirect-hop re-validation (redirect→169.254.169.254 blocked), cross-origin credential stripping, redirect cap, plus trajectory-purpose pass-through (sync/async/throw).Every current develop deploy run dies earlier, at
Build linked elizaOS workspaces(bun run build:core):(e.g. runs 28694656324, 28694875576 — all 3 deploy jobs, deterministic).
@elizaos/cloud-routingIS inCORE_BUILD_PACKAGESand in core'sdependencies, so this looks like an install/turbo-graph issue in the deploy job, from the #12092 item-28 cloud-routing single-sourcing. #12650 fixed only the snap variant. Both blockers must be clear before the next develop→main promote deploys; filing separately.urgent: unblocks promote #12051 money-fix deploy
[cloud-security]