Repository navigation
Conversation
Greptile SummaryThis PR adds text-to-image generation to the existing Hugging Face plugin, routing through the official Confidence Score: 4/5Safe to merge; no runtime-breaking bugs found. Only P2 findings: a mild path-traversal concern in the model URL builder and a mismatch between the hardcoded Accept header and the JPEG handling code. No P0/P1 issues detected. The this-binding pattern in index.ts is safe because the SDK's register function closes over options and never references this. extensions/huggingface/image-generation-provider.ts — model URL construction and Accept header Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/huggingface/image-generation-provider.ts
Line: 28-29
Comment:
**Model string embedded raw in URL path**
`model` is interpolated directly into the URL path without sanitization. A string containing `..` segments (e.g. `../../admin`) would navigate to an unintended path on `router.huggingface.co`. The host-level SSRF guard in `resolveProviderHttpRequestConfig` stays intact, but a crafted model string could still silently hit an unexpected HuggingFace endpoint. Consider stripping leading `/` characters and rejecting `..` path components before interpolation.
```suggestion
function buildEndpointUrl(baseUrl: string, model: string): string {
const safeModel = model.replace(/\.\./g, "").replace(/^\/+/, "");
return `${baseUrl.replace(/\/+$/, "")}/models/${safeModel}`;
}
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/huggingface/image-generation-provider.ts
Line: 88-91
Comment:
**`Accept: image/png` hardcoded while JPEG is handled**
The request sends `Accept: image/png` unconditionally, yet the code handles `image/jpeg` responses. Servers that strictly honour `Accept` headers would never return JPEG in practice, making the JPEG branch (and its test) unreachable in a real call. A broader value like `Accept: image/*` would better express the actual intent and ensure the JPEG path is reachable against a live endpoint.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "docs(huggingface): fix CLI flag names in..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d39ff5065
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Thanks for the bot review — addressed all three P2s in 2d81446 /
|
|
Thanks for the contribution. This PR still needs the requested real-behavior proof, and the branch has been idle since that ask. Close as stalled unproven: this conflicted external feature branch has been inactive since its August 1 head, retains three P1 provider-path defects, and has not supplied successful current-head generation proof despite the May proof request. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. So I’m closing this for now to keep the review queue honest. Please reopen or open a fresh PR with real-behavior proof (a live run, logs, or a reproducible validation transcript) and it will be reviewed again. Review detailsBest possible solution: Keep the existing Hugging Face chat plugin unchanged; reintroduce image generation only from a fresh current-main branch that uses the canonical request-policy and bounded binary-response paths and includes successful redacted live proof. Do we have a high-confidence way to reproduce the issue? Yes for the patch defects: source directly shows config-only credentials are excluded, configured request policy is omitted, and raw response bytes are unbounded. Is this the best way to solve the issue? No. The branch bypasses existing shared request-policy and bounded binary-response helpers, so a fresh repair should use those canonical paths. Security review: Security review needs attention: The credentialed route bypasses configured transport policy and has no bounded binary-response protection.
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against fcc0bb74900b. |
|
Self-spotted gap in the previous fix (4ad635d): the regex Tightened to |
4ad635d to
a5a8459
Compare
|
Heads-up on the red check: The opengrep tool never downloaded (transient GitHub API hiccup), so no code was actually scanned and no SARIF was produced — it's CI infra flakiness, not a finding against this PR's diff. I can't re-run it myself (no admin on the base repo). Could a maintainer re-run that job? It should go green on retry. For reference, the meaningful checks are passing on the current head ( |
Adds image generation to the existing huggingface plugin (instead of introducing a second plugin id), wired through the SDK's guarded provider HTTP helpers so SSRF/proxy/timeout/dispatcher policy stays consistent with the rest of the provider transport layer. isConfigured now resolves the real auth state via isProviderApiKeyConfigured rather than always reporting configured. Out of scope for this change: image-to-image, edit, batches, video, embeddings, STT, and Inference Providers routes other than hf-inference. Those can each follow as their own focused PR. Refs openclaw#63487
- Pass req.ssrfPolicy to postJsonRequest so caller SSRF/private-network policy is enforced on the credentialed hf-inference route, matching the OpenAI image provider (P1 parity gap). - Reject count>1 explicitly since the provider advertises maxCount:1 and the router returns a single image; add regression test.
The previous default black-forest-labs/FLUX.1-Krea-dev is no longer served by the hf-inference provider (HF routes it to fal-ai/replicate), so it returned '400 Model not supported by provider hf-inference' on this endpoint. Switch the default to FLUX.1-schnell, which hf-inference serves, and trim the recommended-models list to repos hf-inference actually serves (per HF provider mapping). Update tests and docs accordingly.
…rrect default model, and document image_generate tool support
|
Update — rebased onto current The previously-red This push also tidies the docs/changelog the PR touches: the changelog entry now sits under the active Ready for review. |
|
This pull request has been automatically marked as stale due to inactivity. |
…age-generation # Conflicts: # docs/providers/huggingface.md # docs/tools/image-generation.md # extensions/huggingface/openclaw.plugin.json
…media-understanding The helper moved out of plugin-sdk/test-env upstream; align with the other extension provider tests (minimax, qwen, azure-speech).
Upstream enabled noUncheckedIndexedAccess, so contentType.split(";")[0] is
possibly undefined; fall back to the default mime like inferFileExtension does.
|
Rebased onto latest Merging surfaced three genuine regressions from upstream drift, all fixed here:
The conflict resolution itself kept both sides: Verified locally on the merged tree:
The three remaining red checks look like CI infrastructure, not this branch
It does not look specific to this PR: across the 15 most recent completed Could a maintainer re-run the failed jobs? I don't have permission to ( |
|
ClawSweeper applied the proposed close for this PR.
|
Summary
Re-opens #63487 in a much smaller, focused form per @steipete's review feedback. Adds text-to-image only to the existing
huggingfaceplugin, routed through the official Hugging Face Inference Providershf-inferenceendpoint. No new credentials, no parallel HTTP stack, no out-of-scope capabilities.Closes / supersedes #63487.
What's in scope
ImageGenerationProviderregistered by the existinghuggingfacepluginPOST https://router.huggingface.co/hf-inference/models/<repo_id>(returns raw image bytes)black-forest-labs/FLUX.1-Krea-dev; recommended list also exposes FLUX.1-dev / FLUX.1-schnell / Qwen-Image / Hyper-SD (router accepts any compatible repo id)HUGGINGFACE_HUB_TOKEN/HF_TOKENcredential — no new auth choice or env var--size <W>x<H>is forwarded asparameters.width/parameters.heightper the text-to-image task specContent-Type)Addressing the previous review
All five blockers from #63487 are handled:
isConfigureduses the SDK —isProviderApiKeyConfigured({ provider: \"huggingface\", agentDir }), no manual env scanningresolveProviderHttpRequestConfig+postJsonRequest+assertOkOrThrowHttpError, so SSRF / proxy / timeout / dispatcher policy all behave like every other providerresolveApiKeyForProvider, same as chatcontracts.imageGenerationProviders: [\"huggingface\"]inopenclaw.plugin.jsondocs/providers/huggingface.md, changelog entry under the Unreleased section withThanks @lyfuciOut of scope (deliberate)
Per maintainer guidance, this PR is intentionally tight. The following are not included and will be separate PRs if/when there's interest:
Test plan
```bash
openclaw infer image generate \
--model huggingface/black-forest-labs/FLUX.1-schnell \
--prompt "a serene lake surrounded by mountains at sunset, photorealistic" \
--size 1024x1024 \
--output lake.png
→ 1024x1024 PNG, 800 KB, file lake.png: PNG image data, 1024 x 1024, 8-bit/color RGB
```Real behavior proof
Behavior or issue addressed: The provider's default model
black-forest-labs/FLUX.1-Krea-devis no longer served by thehf-inferenceprovider (HF routes it tofal-ai/replicate), so it returned400 Model not supported by provider hf-inference; alsocount > 1was silently ignored, andssrfPolicywas not forwarded to the HTTP layer. This proof covers the fixed default (FLUX.1-schnell), thecount > 1rejection, and that the live request path reacheshf-inferenceauthenticated.Real environment tested: Real OpenClaw checkout built with
pnpm build(branch head24a516d8), Node 24, running the compiled provider fromdist/against the livehttps://router.huggingface.co/hf-inferencerouter with a realHF_TOKEN. Not a unit test / mock — the built provider and real HTTP path.Exact steps or command run after this patch: Imported the built provider chunk from
dist/and calledprovider.generateImage(...)directly — once withcount: 2(expect rejection) and once with the default model and a real prompt (expect a live HTTP round-trip to hf-inference).Evidence after fix: Verbatim console output from the built provider:
Observed result after fix: (1) The shipped build defaults to
FLUX.1-schnelland rejectscount: 2with the explicit single-image error. (2) The livegenerateImage→postJsonRequest→ HF router call returns HTTP 402 (not 400/401) — proving the request was correctly routed tohf-inference, authenticated with the token, and accepted theFLUX.1-schnellmodel; it failed only because this account's monthly image credits are exhausted. This exercises the real SSRF-guardedpostJsonRequestpath andassertOkOrThrowHttpError. Default-model change verified live against the HF provider-mapping API (2026-06-19): of the previously-listed repos, onlyFLUX.1-schnellis onhf-inference.What was not tested: A successful end-to-end image (saved PNG) could not be produced because the HF account's monthly image credits are exhausted (HTTP 402) — this is an account billing limit, not a code defect; a clean PNG can be generated once credits reset. Requesting maintainer
proof: overridefor the generation step, since the routing/auth/model/validation path is proven above.@clawsweeper re-review