{"record":{"id":"5277438d0be7928d","repo":"Significant-Gravitas/AutoGPT","slug":"execution-not-found-527743","errorCode":null,"errorMessage":"Execution not found","messagePattern":"Execution not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"autogpt_platform/backend/backend/api/features/v1.py","lineNumber":2269,"sourceCode":"\n@v1_router.post(\n    \"/graphs/{graph_id}/executions/{graph_exec_id}/share\",\n    dependencies=[Security(requires_user)],\n)\nasync def enable_execution_sharing(\n    graph_id: Annotated[str, Path],\n    graph_exec_id: Annotated[str, Path],\n    user_id: Annotated[str, Security(get_user_id)],\n    ctx: Annotated[RequestContext, Security(get_request_context)],\n    _body: ShareRequest = Body(default=ShareRequest()),\n) -> ShareResponse:\n    \"\"\"Enable sharing for a graph execution.\"\"\"\n    # Verify the execution belongs to the user\n    execution = await execution_db.get_graph_execution(\n        user_id=user_id, execution_id=graph_exec_id\n    )\n    if not execution:\n        raise HTTPException(status_code=404, detail=\"Execution not found\")\n\n    # Generate a unique share token\n    share_token = generate_share_token()\n\n    # Remove stale allowlist records before updating the token — prevents a\n    # window where old records + new token could coexist.\n    await execution_db.delete_shared_execution_files(execution_id=graph_exec_id)\n\n    # Update the execution with share info — the underlying update_many\n    # also enforces (id, user_id) at the DB layer, so a TOCTOU delete\n    # between the pre-check above and this write surfaces as 404 rather\n    # than a silent no-op.\n    try:\n        await execution_db.update_graph_execution_share_status(\n            execution_id=graph_exec_id,\n            user_id=user_id,\n            is_shared=True,\n            share_token=share_token,","sourceCodeStart":2251,"sourceCodeEnd":2287,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/v1.py#L2251-L2287","documentation":"Raised (404) by POST /graphs/{graph_id}/executions/{graph_exec_id}/share when execution_db.get_graph_execution(user_id, graph_exec_id) returns nothing — the execution does not exist for this user, so sharing is refused before any share token is generated. Note the pre-check omits organization_id, unlike the GET path.","triggerScenarios":"Clicking 'Share' on a run that was deleted or retention-expired, an execution ID from another user, or a stale share dialog after the run list refreshed.","commonSituations":"Share dialogs left open while the underlying run is cleaned up; deep links to old runs after a workspace reset; attempting to share onboarding/sample executions that were purged.","solutions":["Verify the execution appears in the user's run list (GET executions) before exposing the share action.","On 404, close the share dialog and show 'run no longer available' — do not retry.","Backend-side, hide share buttons for executions older than the retention window."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const runs = await api.listExecutions(graphId);\nif (!runs.some(r => r.execution_id === graphExecId)) { closeShareDialog('Run no longer available'); return; }\nawait api.shareExecution(graphId, graphExecId);","typeGuard":"const isShareableExecution = (id: string, runs: {execution_id: string}[]) => runs.some(r => r.execution_id === id);","tryCatchPattern":"catch (e) { if (e.response?.status === 404 && /Execution not found/.test(e.response.data.detail)) { closeShareDialog(); notifyRunExpired(); } else throw e; }","preventionTips":["Hide share actions for runs outside the retention window.","Close stale share dialogs when the run list refreshes or the run disappears.","Do not retry share on 404 — the execution is gone; link users to a fresh run instead."],"tags":["api","execution","sharing","http-404","not-found"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}