Significant-Gravitas/AutoGPT · error · HTTPException

Execution {execution_id} not found for user {user_id}

Error message

Execution {execution_id} not found for user {user_id}

What it means

Raised by the enable-sharing endpoint (POST on a graph execution's share resource) when the DB-layer owner-gated update `update_graph_execution_share_status(execution_id, user_id, ...)` raises NotFoundError. The (id, user_id) tuple is enforced in the database itself, so this fires when no AgentGraphExecution row matches both the execution ID in the path and the authenticated user, including a TOCTOU delete between the endpoint's earlier pre-check and this write. It is deliberately a 404 rather than a silent no-op.

Source

Thrown at autogpt_platform/backend/backend/api/features/v1.py:2291

    # Remove stale allowlist records before updating the token — prevents a
    # window where old records + new token could coexist.
    await execution_db.delete_shared_execution_files(execution_id=graph_exec_id)

    # Update the execution with share info — the underlying update_many
    # also enforces (id, user_id) at the DB layer, so a TOCTOU delete
    # between the pre-check above and this write surfaces as 404 rather
    # than a silent no-op.
    try:
        await execution_db.update_graph_execution_share_status(
            execution_id=graph_exec_id,
            user_id=user_id,
            is_shared=True,
            share_token=share_token,
            shared_at=datetime.now(timezone.utc),
        )
    except NotFoundError as exc:
        raise HTTPException(status_code=404, detail=str(exc))

    # Create allowlist of workspace files referenced in outputs
    await execution_db.create_shared_execution_files(
        execution_id=graph_exec_id,
        share_token=share_token,
        user_id=user_id,
        outputs=execution.outputs,
    )

    # Return the share URL
    frontend_url = settings.config.frontend_base_url or "http://localhost:3000"
    share_url = f"{frontend_url}/share/{share_token}"

    return ShareResponse(share_url=share_url, share_token=share_token)


@v1_router.delete(
    "/graphs/{graph_id}/executions/{graph_exec_id}/share",

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Verify the execution ID exists and is owned by the same authenticated user (GET the execution first) and re-check the UI state.
  2. If the error appears immediately after a valid fetch, check whether another process (cleanup job, other tab) deleted the execution and refresh the executions list.
  3. In integration tests, ensure the execution is created with the same user_id that the share request authenticates as.
  4. Treat 404 as terminal for this execution — do not retry the share request with the same IDs.

Example fix

// before
const res = await fetch(`/api/graphs/${gid}/executions/${eid}/share`, {method:'POST'});
// after — refresh the execution list and drop stale references on 404
const res = await fetch(`/api/graphs/${gid}/executions/${eid}/share`, {method:'POST'});
if (res.status === 404) {
  await queryClient.invalidateQueries({queryKey: ['executions', gid]});
  toast.error('This execution no longer exists.');
}
Defensive patterns

Strategy: try-catch

Validate before calling

const exec = await api.getExecution(gid, eid);
if (!exec || exec.userId !== currentUserId) {
  throw new Error('Execution not available for sharing');
}

Try / catch

try {
  const share = await api.enableSharing(gid, eid);
} catch (e) {
  if (e.status === 404) {
    // execution gone or not owned — drop from UI, do not retry
    await refreshExecutions(gid);
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: POST /v1/graphs/{graph_id}/executions/{graph_exec_id}/share where graph_exec_id does not exist, belongs to another user, or was deleted by a concurrent request/retention job between the pre-check and the share-status write.

Common situations: Stale frontend holding an execution ID after the user switched accounts or the execution was purged; test setups that create executions under a different user ID; concurrent deletion while the user clicks 'Share'.

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/ee7c2753f169db12. Report an issue: GitHub.