lfnovo/open-notebook · error · HTTPException

Error embedding content: {str(e)}

Error message

Error embedding content: {str(e)}

What it means

Catch-all 500 from POST /api/embed for any unexpected failure during the embedding flow that isn't HTTP, NotFound, or OpenNotebookError. The underlying exception message is appended to the detail, so the response carries the specific cause.

Source

Thrown at api/routers/embedding.py:127

                message=message,
                item_id=item_id,
                item_type=item_type,
                command_id=command_id,
            )

    except HTTPException:
        raise
    except NotFoundError:
        raise HTTPException(
            status_code=404, detail=f"{embed_request.item_type} not found"
        )
    except OpenNotebookError:
        raise
    except Exception as e:
        logger.error(
            f"Error embedding {embed_request.item_type} {embed_request.item_id}: {str(e)}"
        )
        raise HTTPException(
            status_code=500, detail=f"Error embedding content: {str(e)}"
        )

View on GitHub (pinned to a7de90d38a)

Solutions

  1. Read the appended str(e) and the log line 'Error embedding <type> <id>: ...' for the exact cause
  2. If it's a provider auth error, update the embedding model's credential API key in the Models/Credentials section
  3. Verify network egress to the embedding provider from the API host
  4. Retry after fixing the root cause; embedding is resubmittable
Defensive patterns

Strategy: try-catch

Validate before calling

// verify the embedding model's credential works before embedding
const models = await api.listModels();
const emb = models.find(m => m.isDefault && m.type === 'embedding');
if (!emb?.credentialId) throw new Error('Embedding model has no valid credential');

Try / catch

try {
  await api.embed(payload);
} catch (e) {
  if (e.status === 500) showError(`Embedding failed: ${e.detail}`); // detail carries the provider cause
  throw e;
}

Prevention

When it happens

Trigger: POST /api/embed when the embedding model provider call fails (invalid API key, network error), the item's content cannot be prepared for embedding, or the DB read of the item raises an unexpected error type.

Common situations: Embedding model credential expired/revoked, provider outage, oversized/empty content hitting an edge case, or DB connectivity problems mid-flow.

Related errors


AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27). Data as JSON: /api/errors/86ae0c5467de6972. Report an issue: GitHub.