Comfy-Org / Comfy-Org/ComfyUI_frontend

Handle getEmbeddings HTTP failures during A1111 import

Open
#14,737 1 comment 1 reaction 1 assignee Claimed by @christian-byrne View on GitHub
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Summary

Improve error handling for `getEmbeddings` when the backend returns an HTTP
failure during an A1111 PNG import.

## Required changes

- Update `getEmbeddings` in `src/scripts/api.ts` to distinguish a successful
empty embeddings response from a transport or HTTP failure.
- Check `Response.ok` before treating the response body as embeddings data.
- Convert non-OK responses and invalid response bodies into an error that
callers can identify as a backend or connectivity failure.
- Update the A1111 import and file-load error path as needed so the UI does
not report the workflow-parsing message `"Unable to find workflow in
"` for a backend failure.
- Review other `getEmbeddings` callers and preserve or explicitly update their
error handling contract.

## Rationale

Currently, an HTTP 500 response with a valid JSON body can resolve from
`getEmbeddings` and allow an A1111 import to continue with an empty embeddings
list and no user feedback. An HTTP 500 response with an HTML body can cause
`.json()` to throw `SyntaxError`. That error propagates through `importA1111`
and `handleFile` to `ui.ts`, which reports a workflow-parsing error instead of
a backend failure.

This behavior predates PR #14556. It affects an API helper with other callers,
so it requires a dedicated pull request.

## Affected areas

- `src/scripts/api.ts` (`getEmbeddings`)
- `src/scripts/pnginfo.ts` (`importA1111`)
- `src/scripts/app.ts` and `src/scripts/ui.ts` file import error handling
- Other callers of `getEmbeddings`
- Relevant unit tests

## Acceptance criteria

- A non-OK embeddings response does not silently become an empty embeddings
result.
- A malformed embeddings response produces an actionable backend or
connectivity error.
- A1111 import shows a backend-specific error for embeddings request failures.
- A legitimate empty embeddings result remains distinguishable from a failed
request.
- Tests cover non-OK JSON, non-OK non-JSON, and successful empty embeddings
responses.
- Existing `getEmbeddings` callers have defined error behavior.

## Backlinks

- Surfaced in PR #14556:
https://github.com/Comfy-Org/ComfyUI_frontend/pull/14556
- Review comment:
https://github.com/Comfy-Org/ComfyUI_frontend/pull/14556#discussion_r3708967876

Requested by @christian-byrne.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.