fix(providers): route image generation through shared transport#59729
Conversation
Greptile SummaryThis PR routes image generation requests from the OpenAI, MiniMax, and fal providers through the shared Key changes:
The previously flagged issue (MiniMax discarding the One issue found: the new Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/media-understanding/shared.ts
Line: 141-147
Comment:
**`auditContext` silently dropped when `allowPrivateNetwork` and `dispatcherPolicy` are both falsy**
The `auditContext` parameter is added to the function signature but will be silently ignored whenever `allowPrivateNetwork` is `false` **and** `dispatcherPolicy` is `undefined` — which is the common (non-private-network) path. The ternary condition selects `undefined` as the entire options object in that case, so `auditContext` never reaches `fetchWithSsrFGuard`.
Any future caller that passes `auditContext` to a standard (non-private-network) `postJsonRequest` call will get no audit trail without any error or warning.
The same issue exists in the parallel block of `postTranscriptionRequest` (lines 112–118).
Fix both by including `auditContext` in the guard condition:
```suggestion
params.allowPrivateNetwork || params.dispatcherPolicy || params.auditContext
? {
...(params.allowPrivateNetwork ? { ssrfPolicy: { allowPrivateNetwork: true } } : {}),
...(params.dispatcherPolicy ? { dispatcherPolicy: params.dispatcherPolicy } : {}),
...(params.auditContext ? { auditContext: params.auditContext } : {}),
}
: undefined,
```
The same one-line change is needed in `postTranscriptionRequest` at line 112.
How can I resolve this? If you propose a fix, please make it concise.Reviews (2): Last reviewed commit: "fix(providers): use normalized minimax i..." | Re-trigger Greptile |
|
@greptileai review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 726deee8ae
ℹ️ 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".
| @@ -137,14 +163,49 @@ export async function postJsonRequest(params: { | |||
| ? { | |||
There was a problem hiding this comment.
Pass auditContext even when no SSRF policy is set
postJsonRequest only forwards an options object when allowPrivateNetwork or dispatcherPolicy is truthy, so calls that provide only auditContext silently drop it. In that case fetchWithTimeoutGuarded never receives the context, and SSRF block logs fall back to the generic context instead of the caller-specific one. This affects observability/security triage for default-network requests and makes the new audit-context sanitization path ineffective for this helper shape.
Useful? React with 👍 / 👎.
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🔵 Terminal escape / log injection via untrusted HTTP error body in assertOkOrThrowHttpError
Description
This allows terminal escape injection (and potentially log manipulation in terminals that interpret ANSI sequences) when the error is surfaced in logs/CLI output. Vulnerable code: const detail = await readErrorResponse(res);
const suffix = detail ? `: ${detail}` : "";
throw new Error(`${label} (HTTP ${res.status})${suffix}`);RecommendationSanitize provider error bodies before including them in error messages/logs. At minimum, strip C0/C1 control characters (including ESC) from the decoded text, similar to Example fix: function sanitizeErrorDetail(detail: string): string {
return detail
.replace(/\p{Cc}+/gu, " ") // remove control chars (includes \x1b)
.replace(/\s+/g, " ")
.trim();
}
// ...
const rawDetail = await readErrorResponse(res);
const detail = rawDetail ? sanitizeErrorDetail(rawDetail) : undefined;Optionally, also consider only including error details when running in debug mode, or logging structured fields separately from the main message. Analyzed PR: #59729 at commit Last updated on: 2026-04-02T15:54:30Z |
* fix(providers): route image generation through shared transport * fix(providers): use normalized minimax image base url * fix(providers): fail closed on image private routes * fix(providers): bound shared HTTP fetches
…claw#59729) * fix(providers): route image generation through shared transport * fix(providers): use normalized minimax image base url * fix(providers): fail closed on image private routes * fix(providers): bound shared HTTP fetches
…claw#59729) * fix(providers): route image generation through shared transport * fix(providers): use normalized minimax image base url * fix(providers): fail closed on image private routes * fix(providers): bound shared HTTP fetches
…claw#59729) * fix(providers): route image generation through shared transport * fix(providers): use normalized minimax image base url * fix(providers): fail closed on image private routes * fix(providers): bound shared HTTP fetches
…claw#59729) * fix(providers): route image generation through shared transport * fix(providers): use normalized minimax image base url * fix(providers): fail closed on image private routes * fix(providers): bound shared HTTP fetches
…claw#59729) * fix(providers): route image generation through shared transport * fix(providers): use normalized minimax image base url * fix(providers): fail closed on image private routes * fix(providers): bound shared HTTP fetches
…claw#59729) * fix(providers): route image generation through shared transport * fix(providers): use normalized minimax image base url * fix(providers): fail closed on image private routes * fix(providers): bound shared HTTP fetches
Summary
Verification