lfnovo/open-notebook · error · HTTPException

Failed to queue embedding: {str(e)}

Error message

Failed to queue embedding: {str(e)}

What it means

500 from POST /api/embed in the async path: submitting the background embedding command to the job queue failed. The exception message from the command-submission layer is appended, so the detail string carries the underlying cause.

Source

Thrown at api/routers/embedding.py:71

                command_id = await CommandService.submit_command_job(
                    "open_notebook",
                    command_name,
                    command_input,
                )

                logger.info(f"Submitted async {command_name} command: {command_id}")

                return EmbedResponse(
                    success=True,
                    message="Embedding queued for background processing",
                    item_id=item_id,
                    item_type=item_type,
                    command_id=command_id,
                )

            except Exception as e:
                logger.error(f"Failed to submit async embedding command: {e}")
                raise HTTPException(
                    status_code=500, detail=f"Failed to queue embedding: {str(e)}"
                )

        else:
            # DOMAIN MODEL PATH: Submit job via domain model convenience methods
            # These methods internally call submit_command() - still fire-and-forget
            logger.info(f"Using domain model path for {item_type} {item_id}")

            command_id = None

            # Get the item and submit embedding job
            if item_type == "source":
                source_item = await Source.get(item_id)

                # Submit embed_source job (returns command_id for tracking)
                command_id = await source_item.vectorize()
                message = "Source embedding job submitted"

View on GitHub (pinned to a7de90d38a)

Solutions

  1. Start the worker: make worker-start (podcasts, embeddings and source processing are async jobs that silently fail without it)
  2. Read the appended str(e) in the 400/500 detail and the log line 'Failed to submit async embedding command' for the root cause
  3. Verify SurrealDB health: make status; restart the DB then the API and worker
  4. Retry the embed once the full stack (DB → API → worker) is running
Defensive patterns

Strategy: validation

Validate before calling

// ensure worker is up before submitting async embeds
const status = await api.getWorkerStatus?.(); // or make status server-side
if (!status?.workerRunning) throw new Error('Start the worker (make worker-start) before async embedding');

Try / catch

try {
  await api.embed({ item_id, item_type: 'source', async_processing: true });
} catch (e) {
  if (e.status === 500 && /queue embedding/i.test(e.detail)) showError('Queue unavailable — is the worker running?');
  throw e;
}

Prevention

When it happens

Trigger: POST /api/embed with async_processing=true when the command cannot be queued — e.g. the surreal-commands worker infrastructure is unavailable or command submission raises (serialization error, DB write to the job table failing).

Common situations: Worker tier not running (make worker-start skipped): jobs queue forever or submission fails depending on DB state; or SurrealDB down when writing the command record.

Related errors


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