{"record":{"id":"1ad057a4af1572ab","repo":"plandex-ai/plandex","slug":"not-found-1ad057","errorCode":null,"errorMessage":"Not found","messagePattern":"Not found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"error","filePath":"app/server/handlers/plans_changes.go","lineNumber":473,"sourceCode":"\n\tres, err := db.Conn.Exec(\"UPDATE plans SET archived_at = NOW() WHERE id = $1\", planId)\n\n\tif err != nil {\n\t\tlog.Printf(\"Error archiving plan: %v\\n\", err)\n\t\thttp.Error(w, \"Error archiving plan: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\trowsAffected, err := res.RowsAffected()\n\tif err != nil {\n\t\tlog.Printf(\"Error getting rows affected: %v\\n\", err)\n\t\thttp.Error(w, \"Error getting rows affected: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif rowsAffected == 0 {\n\t\tlog.Println(\"Plan not found\")\n\t\thttp.Error(w, \"Not found\", http.StatusNotFound)\n\t\treturn\n\t}\n\n\tlog.Println(\"Successfully archived plan\", planId)\n}\n\nfunc UnarchivePlanHandler(w http.ResponseWriter, r *http.Request) {\n\tauth := Authenticate(w, r, true)\n\tif auth == nil {\n\t\treturn\n\t}\n\n\tlog.Println(\"Received request for UnarchivePlanHandler\")\n\n\tvars := mux.Vars(r)\n\tplanId := vars[\"planId\"]\n\tlog.Println(\"planId: \", planId)\n","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/plans_changes.go#L455-L491","documentation":"The archive UPDATE ran without error but affected 0 rows, meaning no plan with the given planId existed at UPDATE time; the handler returns HTTP 404 'Not found'. This is a race/consistency check after the state guard passed.","triggerScenarios":"planId in the URL doesn't match any row in plans (typo, wrong environment, plan deleted between the authorizePlanArchive SELECT and the UPDATE, or the plan was removed by a concurrent operation).","commonSituations":"Client caching a stale planId after the plan was deleted; archiving against the wrong database/environment (staging vs prod); race with a delete operation; user following an outdated link.","solutions":["Verify the planId exists (query plans by id) in the environment you're hitting","Re-fetch the plan list and retry with a fresh planId","Check you're pointed at the intended database/environment","Handle 404 in the client by refreshing plan state rather than retrying"],"exampleFix":"// before\nawait archivePlan('abc123'); // stale id → 404\n// after\nconst plans = await listPlans();\nif (plans.some(p => p.id === id)) await archivePlan(id); else refreshList();","handlingStrategy":"validation","validationCode":"const plans = await listPlans();\nif (!plans.some(p => p.id === planId)) throw new Error(`Plan ${planId} does not exist`);\nawait archivePlan(planId);","typeGuard":"function planExists(plans, id) { return Array.isArray(plans) && plans.some(p => p && p.id === id); }","tryCatchPattern":"try { await archivePlan(planId); } catch (e) { if (e.status === 404) { await refreshPlans(); throw new Error('Plan not found — it may have been deleted'); } throw e; }","preventionTips":["Re-fetch plan ids rather than using cached/stale ones","Confirm you're targeting the right environment/database","Handle 404 by refreshing state, not retrying","Watch for concurrent deletes if multiple operators manage plans"],"tags":["http","not-found","database","go"],"backgroundTag":"resource-not-found","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}