Repository navigation
fix: reject getEmbeddings on HTTP failures and report A1111 import connectivity distinctly - #14931
MaanilVerma wants to merge 3 commits into
Conversation
…ortA1111 propagates the failure untouched
…onnectivity errors distinctly
…owing, extract the triplicated failure detail
📝 WalkthroughWalkthroughThe API now identifies transport and HTTP failures from ChangesA1111 embedding failure handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
🎭 Playwright: ✅ 1786 passed, 0 failed · 3 flaky📊 Browser Reports
🎨 Storybook: ✅ Built — View Storybook |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/scripts/api.getEmbeddings.test.ts`:
- Around line 42-95: Strengthen the error assertions for api.getEmbeddings in
src/scripts/api.getEmbeddings.test.ts:42-95 to verify ApiHttpError identity plus
endpoint and status metadata, including status 0 for transport failures and body
details for both readable and unreadable failure responses. In
src/scripts/app.test.ts:1625-1636, store the RangeError instance and assert
rejection with rejects.toBe(failure) to verify unchanged propagation.
In `@src/scripts/api.ts`:
- Around line 212-214: Remove the export modifier from the httpFailureDetail
function so it remains module-local while preserving its current signature and
behavior.
In `@src/scripts/app.ts`:
- Line 152: Separate the type-only ComfyApi import from the runtime import in
src/scripts/app.ts: add a dedicated import type statement for ComfyApi and leave
ApiHttpError, PromptExecutionError, and api in the regular import.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: a3da4333-6777-4307-8cd3-761c5d708ec4
📒 Files selected for processing (6)
src/locales/en/main.jsonsrc/scripts/api.getEmbeddings.test.tssrc/scripts/api.tssrc/scripts/app.test.tssrc/scripts/app.tssrc/scripts/pnginfo.test.ts
| it('rejects identifiably on a non-ok response with a JSON body', async () => { | ||
| fetchApiSpy.mockResolvedValueOnce(jsonResponse(500, { error: 'boom' })) | ||
|
|
||
| await expect(api.getEmbeddings()).rejects.toSatisfy( | ||
| (e) => | ||
| e instanceof Error && | ||
| e.name === 'ApiHttpError' && | ||
| e.message.includes('/embeddings') && | ||
| e.message.includes('500') | ||
| ) | ||
| }) | ||
|
|
||
| it('keeps the status even when reading the failure body itself rejects', async () => { | ||
| fetchApiSpy.mockResolvedValueOnce({ | ||
| ok: false, | ||
| status: 500, | ||
| json: () => Promise.reject(new SyntaxError('Unexpected token <')), | ||
| text: () => Promise.reject(new Error('body stream lost')) | ||
| } as unknown as Response) | ||
|
|
||
| await expect(api.getEmbeddings()).rejects.toSatisfy( | ||
| (e) => | ||
| e instanceof Error && | ||
| e.name === 'ApiHttpError' && | ||
| e.message.includes('/embeddings') && | ||
| e.message.includes('500') | ||
| ) | ||
| }) | ||
|
|
||
| it('rejects identifiably when the fetch itself fails (backend down)', async () => { | ||
| fetchApiSpy.mockRejectedValueOnce(new TypeError('Failed to fetch')) | ||
|
|
||
| await expect(api.getEmbeddings()).rejects.toSatisfy( | ||
| (e) => | ||
| e instanceof Error && | ||
| e.name === 'ApiHttpError' && | ||
| e.message.includes('/embeddings') && | ||
| e.message.includes('Failed to fetch') | ||
| ) | ||
| }) | ||
|
|
||
| it('rejects identifiably on a non-ok response with an HTML body', async () => { | ||
| fetchApiSpy.mockResolvedValueOnce( | ||
| htmlResponse(502, '<html>bad gateway</html>') | ||
| ) | ||
|
|
||
| await expect(api.getEmbeddings()).rejects.toSatisfy( | ||
| (e) => | ||
| e instanceof Error && | ||
| e.name === 'ApiHttpError' && | ||
| e.message.includes('/embeddings') && | ||
| e.message.includes('502') | ||
| ) | ||
| }) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Assert error identity and metadata, not only error text.
Text-only assertions can pass when the error type or its public metadata changes.
src/scripts/api.getEmbeddings.test.ts#L42-L95: AssertApiHttpErroridentity and itsendpointandstatusfields. Cover status0for transport failures and body details for readable and unreadable responses.src/scripts/app.test.ts#L1625-L1636: Store theRangeErrorinstance and userejects.toBe(failure)to verify unchanged propagation.
As per path instructions, “Tests for getEmbeddings and A1111 import handling should verify … error identity/details.”
📍 Affects 2 files
src/scripts/api.getEmbeddings.test.ts#L42-L95(this comment)src/scripts/app.test.ts#L1625-L1636
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/scripts/api.getEmbeddings.test.ts` around lines 42 - 95, Strengthen the
error assertions for api.getEmbeddings in
src/scripts/api.getEmbeddings.test.ts:42-95 to verify ApiHttpError identity plus
endpoint and status metadata, including status 0 for transport failures and body
details for both readable and unreadable failure responses. In
src/scripts/app.test.ts:1625-1636, store the RangeError instance and assert
rejection with rejects.toBe(failure) to verify unchanged propagation.
Source: Path instructions
| export function httpFailureDetail(status: number | string, body = ''): string { | ||
| return `${status}${body ? ` — ${body}` : ''}` | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -nP --glob '*.{ts,tsx,vue}' \
'(?:import\s*\{[^}]*\bhttpFailureDetail\b|httpFailureDetail\s*\()' srcRepository: Comfy-Org/ComfyUI_frontend
Length of output: 569
Remove the redundant httpFailureDetail export.
httpFailureDetail is only called from src/scripts/api.ts; no external file imports it. Drop export to keep the API surface minimal.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/scripts/api.ts` around lines 212 - 214, Remove the export modifier from
the httpFailureDetail function so it remains module-local while preserving its
current signature and behavior.
Source: Learnings
| import { deserialiseAndCreate } from '@/utils/vintageClipboard' | ||
|
|
||
| import { type ComfyApi, PromptExecutionError, api } from './api' | ||
| import { type ComfyApi, ApiHttpError, PromptExecutionError, api } from './api' |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Separate the type-only import.
Line 152 mixes type ComfyApi with runtime imports. Move ComfyApi to a separate import type statement.
As per coding guidelines, “Use separate import type statements rather than inline type specifiers in mixed imports.”
Proposed fix
-import { type ComfyApi, ApiHttpError, PromptExecutionError, api } from './api'
+import { ApiHttpError, PromptExecutionError, api } from './api'
+import type { ComfyApi } from './api'📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import { type ComfyApi, ApiHttpError, PromptExecutionError, api } from './api' | |
| import { ApiHttpError, PromptExecutionError, api } from './api' | |
| import type { ComfyApi } from './api' |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/scripts/app.ts` at line 152, Separate the type-only ComfyApi import from
the runtime import in src/scripts/app.ts: add a dedicated import type statement
for ComfyApi and leave ApiHttpError, PromptExecutionError, and api in the
regular import.
Sources: Coding guidelines, Learnings
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #14931 +/- ##
========================================
Coverage 78.69% 78.70%
========================================
Files 1864 1864
Lines 115461 115477 +16
Branches 34495 33554 -941
========================================
+ Hits 90864 90883 +19
+ Misses 24055 24052 -3
Partials 542 542
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Summary
api.getEmbeddings()never checkedresp.ok, so a backend failure during an A1111 PNG import either resolved silently with garbage (500 with a JSON body, import proceeds with unresolved embeddings and no feedback) or surfaced as "Unable to find workflow in <file>" (500 with an HTML body, via the SyntaxError from parsing it). Connectivity problems now reject identifiably at the source and the import path reports them as what they are.Changes
api.getEmbeddings()throws a newApiHttpError(endpoint, status, defensive body text) on non-ok responses, and wraps fetch-level rejections as status 0 so a fully unreachable backend is identifiable the same wayapp.handleFile()'s A1111 parameters fall-through catchesApiHttpErrorand shows a connectivity toast; any other rejection propagates unchangedhttpFailureDetail()and reused it incancelJob/cancelJobs, which already built the identical failure string (messages unchanged, their tests stay green)toastMessages.a1111EmbeddingsUnavailableapi.getEmbeddings.test.ts(success, non-ok JSON body, non-ok HTML body, rejecting body read, fetch-level failure), app-level cases pinning the connectivity toast forApiHttpErrorand propagation for everything else, and a pnginfo pin that an embeddings failure rejects before any lifecycle effect runsReview Focus
src/scripts/api.ts: the transport wrap (status 0) is the one behavior judgment call, andgetEmbeddingschanging from always-resolving to rejecting is a contract change on thewindow.comfyAPIsurfacesrc/scripts/app.ts: the catch narrows oninstanceof ApiHttpError; a dedicated test pins that non-connectivity rejections still propagate untoastedNote for extension authors:
api.getEmbeddings()previously resolved whatever a failed response parsed to; it now rejects withApiHttpError. Direct callers should add a catch.Testing
scripts/cicd/check-binary-size.test.ts, a CI-script test untouched by this diff that exits 127 (missing tool) in the sandbox that ran it