Repository navigation
feat(comfy): support custom headers and per-request seed randomization - #130098
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 28, 2026, 4:26 AM ET / 08:26 UTC. ClawSweeper reviewWhat this changesAdds configurable ComfyUI HTTP headers with SecretRef support, per-request workflow seeds, response-error redaction, documentation, and tests. Merge readinessKeep open: the new arbitrary Comfy request-header surface can persist literal credentials unredacted in debug-proxy captures. Priority: P1 Review scores
Verification
How this fits togetherThe Comfy plugin turns workflow configuration into guarded HTTP requests to local or cloud ComfyUI endpoints. Optional debug-proxy capture records those HTTP exchanges for diagnosis. flowchart LR
A[Comfy plugin config] --> B[Header resolution]
B --> C[Workflow request]
C --> D[Guarded HTTP client]
D --> E[ComfyUI endpoint]
D --> F[Debug proxy capture]
F --> G[Captured diagnostics]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The new arbitrary-header feature has a concrete sensitive-data exposure through persisted debug-proxy captures. PR surfaceSource +169, Tests +427, Docs +26, Other 0. Total +622 across 18 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Register configured Comfy header values for canonical redaction before either capture path runs, including ambient global fetch, and add a capture-storage regression covering an arbitrary literal header. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: configure a literal opaque value under an innocuous headers.* name, enable debug-proxy capture, run a Comfy request, and inspect the captured request headers; this was not executed in the read-only checkout. Is this the best way to solve the issue? No: the patch redacts reflected provider errors, but not the debug-proxy persistence path for arbitrary literal header names. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0a068cf3f1ef. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (16 earlier review cycles; latest 8 shown)
|
|
Addressed the two blocking items:
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
fab0127 to
7f28067
Compare
|
Fixed the P1 security finding: headers now resolve through the same SecretInput path @clawsweeper re-review |
7f28067 to
44e45d9
Compare
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
4b16ee6 to
a1495fa
Compare
Local-mode ComfyUI requests only ever sent Content-Type, so a local instance reachable behind HTTP auth (Basic auth, a bearer token) had no way to authenticate. Add a generic headers config key, merged over the plugin's own headers -- same shape as the ollama plugin's established remote.headers pattern, rather than inventing a comfy-specific scheme. Also add optional seedNodeId/seedInputName: without it, a static workflow file's sampler seed never changes between submissions, so every generation was silently identical whenever the operator's workflow relies on a fresh random seed per run.
…xt-only The new headers config accepted only literal strings, so a credential-bearing value (Authorization for a gated ComfyUI instance) had no path to secret storage -- unlike the existing apiKey field, which already resolves through resolveSecretInputString with an env-backed fallback. Mirrors that same pattern per-header, plus the ollama plugin's established header-secret precedent: a header pointed at a SecretRef that can't be resolved fails the request outright instead of silently sending it unauthenticated.
…esolvable ones resolveComfyHeadersConfig only ever resolved env-sourced SecretRefs (a manual process.env fallback bolted onto inspect-mode); any file, keychain, or plugin-backed reference always threw, despite the schema and docs advertising the same SecretRef shape apiKey accepts. Now resolves through resolveConfiguredSecretInputString (the same async resolver the ollama plugin's own headers use) for the non-literal case, so a real non-env credential provider actually works. Separately, isComfyCapabilityConfigured returned true for local mode without ever inspecting headers, so an unavailable Authorization SecretRef advertised an image/video/music tool that would always throw on invocation. Extends the same sync inspect-based veto resolveComfyApiKey already applies for cloud mode's apiKey. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6
…er selection hasUnavailableComfyHeaderSecret treated any non-env SecretRef as unavailable for the isComfyCapabilityConfigured gate, on the theory that inspect mode can't confirm it -- but "can't confirm yet" isn't "won't resolve": the async request path can and does resolve a real file/keychain/plugin-backed ref. That made a perfectly valid, already-working header credential permanently hide the image/video/music tools from the agent, which is a worse outcome than a rare genuinely broken ref surfacing its error at actual invocation. Only a definitely missing/empty env var (decidable synchronously, no I/O) still vetoes. Added a permanent committed integration test (workflow-runtime.header-secrets.integration.test.ts) that proves this, plus the env/non-env header resolution and fail-closed paths, over real sockets with no SDK/ssrf-runtime mocking -- replacing the throwaway proof script from the previous push, which was deleted after running and therefore not rerunnable or reviewable. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6
headers.* accepts and resolves SecretRef values, but the manifest never declared configContracts.secretInputs for that path -- the canonical plugin secret lifecycle (startup materialization, owner diagnostics, audit/configure discovery, resolved-value redaction) only walks manifest-declared paths, so this credential surface was invisible to all of it despite working correctly at request time. apiKey doesn't need the same declaration (it's covered by the separate, already-wired provider-auth system via setup.providers.envVars/providerAuthChoices); headers.* has no other declaration path. Also fixes two smaller findings from the same review pass: the seed-injection test asserted the freshly-generated seed is nonzero, but randomInt(RANDOM_SEED_EXCLUSIVE_MAX) legitimately can (rarely) return 0 -- a flaky assertion, removed; and documents that a configured Content-Type header is ignored specifically on image-upload requests, where the multipart boundary must come from the runtime. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6
The comfy plugin manifest change in e32863dc6cd registered plugins.entries.comfy.config.headers.* as a secret-input target, but the generated docs matrix and its paired markdown list weren't refreshed to match, breaking the docs-sync CI check. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6
…ilures Reuse the Ollama exact-header redactor through the provider HTTP SDK, scrub structured and truncated diagnostics before retaining them, and cover decoded Basic credentials observed in real ComfyUI proxy failures. Preserve optional header and seed behavior while consolidating tests and documenting the shared boundary. Co-authored-by: Markus Hartung <[email protected]>
Skip undefined HeaderRecord values allowed by Node types and document the intentional omission of unsafe parser causes in the lint exception. Actual credential and no-header error behavior remain unchanged. Co-authored-by: Markus Hartung <[email protected]>
Keep the socket fixture compatible with the IncomingHttpHeaders union without changing its reflected-error behavior. Co-authored-by: Markus Hartung <[email protected]>
Track the intentional preserve-caught-error suppression in the explicit inventory: raw JSON parser causes can quote request credentials. The focused inventory and provider HTTP tests pass; runtime behavior is unchanged.
a1495fa to
34873d9
Compare
|
Merged via squash.
|
openclaw#130098) * feat(comfy): support custom headers and per-request seed randomization Local-mode ComfyUI requests only ever sent Content-Type, so a local instance reachable behind HTTP auth (Basic auth, a bearer token) had no way to authenticate. Add a generic headers config key, merged over the plugin's own headers -- same shape as the ollama plugin's established remote.headers pattern, rather than inventing a comfy-specific scheme. Also add optional seedNodeId/seedInputName: without it, a static workflow file's sampler seed never changes between submissions, so every generation was silently identical whenever the operator's workflow relies on a fresh random seed per run. * fix(comfy): resolve headers through the SecretInput path, not plaintext-only The new headers config accepted only literal strings, so a credential-bearing value (Authorization for a gated ComfyUI instance) had no path to secret storage -- unlike the existing apiKey field, which already resolves through resolveSecretInputString with an env-backed fallback. Mirrors that same pattern per-header, plus the ollama plugin's established header-secret precedent: a header pointed at a SecretRef that can't be resolved fails the request outright instead of silently sending it unauthenticated. * fix(comfy): resolve non-env header SecretRefs, hide capability on unresolvable ones resolveComfyHeadersConfig only ever resolved env-sourced SecretRefs (a manual process.env fallback bolted onto inspect-mode); any file, keychain, or plugin-backed reference always threw, despite the schema and docs advertising the same SecretRef shape apiKey accepts. Now resolves through resolveConfiguredSecretInputString (the same async resolver the ollama plugin's own headers use) for the non-literal case, so a real non-env credential provider actually works. Separately, isComfyCapabilityConfigured returned true for local mode without ever inspecting headers, so an unavailable Authorization SecretRef advertised an image/video/music tool that would always throw on invocation. Extends the same sync inspect-based veto resolveComfyApiKey already applies for cloud mode's apiKey. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6 * fix(comfy): don't veto a resolvable non-env header secret from provider selection hasUnavailableComfyHeaderSecret treated any non-env SecretRef as unavailable for the isComfyCapabilityConfigured gate, on the theory that inspect mode can't confirm it -- but "can't confirm yet" isn't "won't resolve": the async request path can and does resolve a real file/keychain/plugin-backed ref. That made a perfectly valid, already-working header credential permanently hide the image/video/music tools from the agent, which is a worse outcome than a rare genuinely broken ref surfacing its error at actual invocation. Only a definitely missing/empty env var (decidable synchronously, no I/O) still vetoes. Added a permanent committed integration test (workflow-runtime.header-secrets.integration.test.ts) that proves this, plus the env/non-env header resolution and fail-closed paths, over real sockets with no SDK/ssrf-runtime mocking -- replacing the throwaway proof script from the previous push, which was deleted after running and therefore not rerunnable or reviewable. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6 * fix(comfy): register header SecretRefs in the plugin secret contract headers.* accepts and resolves SecretRef values, but the manifest never declared configContracts.secretInputs for that path -- the canonical plugin secret lifecycle (startup materialization, owner diagnostics, audit/configure discovery, resolved-value redaction) only walks manifest-declared paths, so this credential surface was invisible to all of it despite working correctly at request time. apiKey doesn't need the same declaration (it's covered by the separate, already-wired provider-auth system via setup.providers.envVars/providerAuthChoices); headers.* has no other declaration path. Also fixes two smaller findings from the same review pass: the seed-injection test asserted the freshly-generated seed is nonzero, but randomInt(RANDOM_SEED_EXCLUSIVE_MAX) legitimately can (rarely) return 0 -- a flaky assertion, removed; and documents that a configured Content-Type header is ignored specifically on image-upload requests, where the multipart boundary must come from the runtime. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6 * docs(secrets): register comfy header SecretRefs in the credential matrix The comfy plugin manifest change in e32863dc6cd registered plugins.entries.comfy.config.headers.* as a secret-input target, but the generated docs matrix and its paired markdown list weren't refreshed to match, breaking the docs-sync CI check. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6 * test(comfy): restore inherited header proof env * fix(comfy): redact reflected request credentials across generation failures Reuse the Ollama exact-header redactor through the provider HTTP SDK, scrub structured and truncated diagnostics before retaining them, and cover decoded Basic credentials observed in real ComfyUI proxy failures. Preserve optional header and seed behavior while consolidating tests and documenting the shared boundary. Co-authored-by: Markus Hartung <[email protected]> * fix(provider-http): handle optional Node header values safely Skip undefined HeaderRecord values allowed by Node types and document the intentional omission of unsafe parser causes in the lint exception. Actual credential and no-header error behavior remain unchanged. Co-authored-by: Markus Hartung <[email protected]> * test(comfy): explicitly stringify reflected proxy header values Keep the socket fixture compatible with the IncomingHttpHeaders union without changing its reflected-error behavior. Co-authored-by: Markus Hartung <[email protected]> * test(provider-http): register credential-safe parser error exception Track the intentional preserve-caught-error suppression in the explicit inventory: raw JSON parser causes can quote request credentials. The focused inventory and provider HTTP tests pass; runtime behavior is unchanged. --------- Co-authored-by: Claude Sonnet 5 <[email protected]> Co-authored-by: Patrick Erichsen <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
The ComfyUI provider plugin's local mode only ever sent
Content-Typeon requests, so a local ComfyUI instance reachable behind HTTP auth (Basic auth, a bearer token, etc.) had no way to authenticate — the only auth path was cloud mode's API key. Separately, a staticworkflow/workflowPathfile's sampler seed never changed between submissions, so any workflow relying on a fresh random seed per generation silently returned the same image every time.Why This Change Was Made
Both gaps block real self-hosted ComfyUI setups that sit behind auth on a non-loopback host and whose workflow graph has a
KSampler-style seed input meant to vary per run — a common, realistic configuration, not an edge case.User Impact
headersconfig key, merged over the plugin's own default headers for both local and cloud mode — same shape as the existingremote.headerspattern used by the ollama plugin. Scoped to the shared connection config only (not per-capability), matching howmode/baseUrl/apiKey/allowPrivateNetworkare already shared-only: a single ComfyUI instance has one auth scheme regardless of which capability (image/video/music) is calling it.seedNodeId/seedInputNameper-capability config keys: when set, a fresh cryptographically-random seed (vianode:crypto'srandomInt, capped belowNumber.MAX_SAFE_INTEGERto avoid JSON float-precision loss) is injected into that workflow node before every submission.openclaw.plugin.json'sconfigSchema(which hasadditionalProperties: false) is updated to declareheadersat the top level, andseedNodeId/seedInputNameboth at the top level and insideimage/video/music, soopenclaw config setvalidation accepts them.Evidence
extensions/comfy/image-generation-provider.test.tscovering: headers merged into the local-mode request, a non-objectheadersvalue being ignored rather than throwing, seed injection producing a fresh safe-integer seed per submission, and an unconfiguredseedNodeIdleaving a workflow's baked-in seed untouched. Full extension suite: 50/50 passing.pnpm tsgo:extensionsandpnpm tsgo:extensions:testclean;oxfmt/oxlintclean.autoreview --mode commitclean (patch is correct (0.99), no accepted findings).image_generatetool call viaopenclaw agentagainst the live gateway process (so the async generation task ran to completion, not a one-shot CLI subprocess). Result:toolSummary: { calls: 1, tools: ["image_generate"], failures: 0 }, task ledgerstatus: succeeded, a real 1024x1024 PNG delivered back into the conversation./historyendpoint (which requires the configured Basic Auth header to succeed at all — a 401 would return no history) and extracted the actual submittedseedvalue from each:1454512374329557,1005139994031622,5705569401396208,58058097759276,7669280134279345— five real, distinct, safe-integer seeds confirming both the auth header and the seed-randomization mechanism work end-to-end in production, not just in the unit tests.Update: SecretInput header resolution (security finding fixed)
Fixed the real P1/security finding:
headersvalues only accepted literal strings, so a credential-bearing value (Authorization) had no path to protected secret storage — the schema rejected a SecretRef object outright, and the runtime silently dropped any non-string value. Both are fixed:openclaw.plugin.json'sheaders.additionalPropertiesnow accepts["string", "object"], matchingapiKey's existing type union.resolveComfyHeadersConfig(renamed fromnormalizeComfyHeadersConfig) resolves each header value through the exact sameresolveSecretInputStringpathapiKeyalready uses, including the env-backed fallback (canResolveEnvSecretRefInReadOnlyPath+process.envread) — mirroring the ollama plugin's established header-secret precedent the reviewer cited.unresolvedRefReason→ throw behavior for a configured-but-unresolvable ref, while an unset/absent header value is still silently skipped (not every header is required).New tests: an env-backed SecretRef header resolves and reaches the wire (same env-fallback path the live-verified deployment already uses for the literal-string case), and a header pointed at a missing env var throws before any HTTP request fires. Full extension suite: 52/52 passing.
autoreviewclean (patch is correct (0.99)).Update: real-behavior proof for the SecretRef header path (current head)
ClawSweeper's last review correctly noted the SecretRef-header path (as opposed to the literal-string case, which had live production proof above) only had mocked-
fetchunit-test evidence. Closed that gap with a real, unmocked run: a plainnode:httpserver standing in for ComfyUI, hit over a real loopback socket by the actualfetchWithSsrFGuard-based request path (ssrf-runtimeis not mocked here, unlike the unit tests) — real DNS/SSRF-guard evaluation, realSecretInputenv resolution, real sockets, current head (44e45d90f):POST /promptsubmit,GET /history/:idpoll,GET /viewdownload) — the SecretRef survives every hop, not just the first.references an unavailable secret) strictly before any socket opens, matching the throw-not-silently-drop behavior described above..live-secretref-proof.test.tsthat skips thessrf-runtimemock and boots a real listener; deleted after capturing this transcript.Update: real ComfyUI proof at current head (
e32863dc6cd)Closed the "current-head real-Comfy SecretRef proof" gap. Ran the actual current-head
buildComfyImageGenerationProvider().generateImage(...)twice against a real, independent self-hosted ComfyUI instance, authenticated via a real env-backed SecretRefAuthorizationheader (Basic auth) resolved throughresolveConfiguredSecretInputString— the exact path this PR's fixes touch:Both real generations completed successfully; the recent seeds pulled back from ComfyUI's own
/historyendpoint (which itself required the same Basic Auth to answer) confirm the SecretRef-authenticated requests genuinely reached the real server. Auth credential and host redacted; hostname/user/password were supplied out-of-band by the repo owner specifically for this verification and referenced only via shell variables, never printed.Maintainer review and final validation
The configuration surface (
headers,seedNodeId,seedInputName) and shared provider HTTP SDK design were explicitly accepted by the maintainer. Existing configurations keep their current behavior: fresh seeds require a configured seed node, and saved workflows are not mutated. The random seed range is[0, 2**48), matching Node'srandomIntcontract. Thanks @hartmark for the feature.Review found a credential-reflection defect in error handling: authenticated proxy responses could expose literal or SecretRef header values, including decoded Basic-auth pairs/passwords. The existing Ollama exact-header redactor now lives in the shared provider HTTP owner; Comfy and Ollama use that single implementation. Error bodies are sanitized before diagnostic extraction/truncation, and request IDs, malformed-JSON causes, and Comfy cloud terminal errors are covered. The old plugin-private redactor paths were removed.
Validation includes 322 owner/sibling tests, a final 10-test real-socket rerun, core/plugin types and targeted lint, and an independent real ComfyUI 0.34.0 run through an authenticating proxy. Real randomized outputs had different RGB pixels; fixed-seed outputs matched. Literal and SecretRef credential reflections were redacted, missing secrets opened no request, and all successful requests were authenticated. The live proof used built-in CPU image/noise nodes rather than a paid service or downloaded model. Detailed repair and live evidence; configuration and security-owner acceptance.
CI exposed two test-maintenance issues, both repaired without changing the live-tested Comfy behavior. The intentional parser-cause lint exception needed an entry in the suppression inventory; its failing reproduction now passes. Separately, current main combined #131545's private channel-start helper with #118157's test importing that old export. The pre-fix test failed three cases; the public-rollback repair passed all 246 reload tests. The equivalent canonical repair then landed independently in #131627, so this branch now rebases onto that fix and drops its duplicate test edit. Core test types also pass after refreshing frozen dependencies and rebuilding stale type-check state. Fresh Codex autoreview found no actionable findings at the configured review threshold.
Production delta, discounting moved files: +224/-55 (net +169). This adds the optional authentication/seed capability and shared credential-safety handling. Test delta: +436/-9 (net +427). No dependency or lockfile changes. The latest ClawSweeper rank-up requests are addressed. Final-head CI passed on
34873d9cf017fb770c83bb3988d48de2489a9f06; native prepare verified that exact head without another rebase.Separate infrastructure follow-up: Testbox full-sync dependency inventory dropped the remote lockfile and
tsx; restoring the exact unchanged lockfile and a frozen install recovered the live run. The test server, proxy, and lease have been stopped.