{"record":{"id":"a7fd483c20773e49","repo":"HKUDS/Vibe-Trading","slug":"no-current-goal","errorCode":null,"errorMessage":"No current goal","messagePattern":"No current goal","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"agent/src/api/sessions_routes.py","lineNumber":492,"sourceCode":"            raise HTTPException(status_code=400, detail=str(exc)) from exc\n        snapshot = goal_store.get_goal_snapshot(goal.goal_id)\n        if snapshot is None:\n            raise HTTPException(status_code=500, detail=\"Goal created but could not be reloaded\")\n        svc.event_bus.emit(session_id, \"goal.created\", {\"goal\": snapshot[\"goal\"]})\n        return snapshot\n\n    @app.get(\n        \"/sessions/{session_id}/goal\",\n        response_model=GoalSnapshotResponse,\n        dependencies=[Depends(require_auth)],\n    )\n    async def get_session_goal(session_id: str):\n        \"\"\"Return the current finance research goal snapshot for a session.\"\"\"\n        _host_validate_path_param(session_id, \"session_id\")\n        _get_existing_session_or_404(session_id)\n        snapshot = _get_goal_store().get_current_snapshot(session_id)\n        if snapshot is None:\n            raise HTTPException(status_code=404, detail=\"No current goal\")\n        return snapshot\n\n    @app.patch(\n        \"/sessions/{session_id}/goal\",\n        response_model=UpdateGoalResponse,\n        dependencies=[Depends(require_auth)],\n    )\n    async def update_session_goal(session_id: str, req: UpdateGoalRequest):\n        \"\"\"Edit the current finance research goal without replacing the session.\"\"\"\n        _host_validate_path_param(session_id, \"session_id\")\n        svc, _session = _get_existing_session_or_404(session_id)\n        from src.goal import StaleGoalError\n\n        if req.objective is None and req.ui_summary is None:\n            raise HTTPException(status_code=400, detail=\"objective or ui_summary is required\")\n\n        goal_store = _get_goal_store()\n        try:","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/api/sessions_routes.py#L474-L510","documentation":"GET /sessions/{session_id}/goal returns the current goal snapshot via get_current_snapshot(session_id); when no goal has been created (or the existing goal is no longer 'current', e.g. archived/completed) the route raises 404 'No current goal'. Note the session itself exists — the 404 is about the goal resource, not the session.","triggerScenarios":"Calling GET /sessions/{id}/goal on a session that never had a goal set, or whose goal was replaced/archived so no current snapshot exists. The session id itself is valid (otherwise the session 404 fires first).","commonSituations":"Client fetches the goal immediately after creating a session but before creating a goal; UI showing a 'current goal' panel for goal-less sessions; flows where goal creation failed earlier and the error was swallowed; goal lifecycle moved it out of current state.","solutions":["Create a goal first with POST /sessions/{id}/goal, then read it","Treat 404 on this route as 'no goal yet' and show an empty state rather than an error","Check goal lifecycle state — completed/archived goals may leave no current goal; create a new one","Sequence client flows so goal read happens only after successful goal creation"],"exampleFix":"# before\nsnap = api.get_session_goal(sid)  # 404 for fresh sessions\n\n# after\ntry:\n    snap = api.get_session_goal(sid)\nexcept NotFound:\n    snap = api.create_session_goal(sid, objective=\"...\", risk_tier=\"LOW_RISK\")","handlingStrategy":"try-catch","validationCode":"# know before you fetch: has a goal been created for this session?\nr = client.get(f\"/sessions/{sid}/goal\")\nhas_goal = r.status_code == 200  # 404 means none set yet (session itself exists)","typeGuard":null,"tryCatchPattern":"try:\n    snapshot = api.get_session_goal(sid)\nexcept NotFoundError:\n    # 404 here means 'no current goal', not 'no session'\n    snapshot = api.create_session_goal(sid, objective=default_objective, risk_tier=\"LOW_RISK\")","preventionTips":["Model 'no current goal' as an expected empty state in UIs","Create the goal before reading it in linear flows","Distinguish this 404 from the session-not-found 404 by checking detail"],"tags":["goals","http-404","not-found","session-state"],"backgroundTag":"resource-not-found","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}