{"record":{"id":"98b3c099bc7a419b","repo":"multica-ai/multica","slug":"delete-runtime-w","errorCode":null,"errorMessage":"delete runtime: %w","messagePattern":"delete runtime: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_runtime.go","lineNumber":235,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\n\truntimeID := args[0]\n\tctx, cancel := cli.APIContext(context.Background())\n\tdefer cancel()\n\n\terr = client.DeleteJSON(ctx, \"/api/runtimes/\"+runtimeID)\n\tif err == nil {\n\t\treturn printRuntimeDeleteResult(cmd, map[string]any{\n\t\t\t\"id\":      runtimeID,\n\t\t\t\"deleted\": true,\n\t\t})\n\t}\n\n\tconflict, ok := runtimeDeleteConflict(err)\n\tif !ok {\n\t\treturn fmt.Errorf(\"delete runtime: %w\", err)\n\t}\n\n\tcascade, _ := cmd.Flags().GetBool(\"cascade\")\n\tif !cascade {\n\t\treturn fmt.Errorf(\n\t\t\t\"delete runtime: runtime has active agents bound to it (%s); rebind them to another runtime first, or rerun with --cascade to unbind them and delete the runtime (the agents and their history are kept)\",\n\t\t\tstrings.Join(conflict.AgentDisplays(), \", \"),\n\t\t)\n\t}\n\n\tbody := map[string]any{\n\t\t\"expected_active_agent_ids\": conflict.AgentIDs(),\n\t}\n\tvar result map[string]any\n\tif err := client.PostJSON(ctx, \"/api/runtimes/\"+runtimeID+\"/unbind-agents-and-delete\", body, &result); err != nil {\n\t\treturn fmt.Errorf(\"cascade delete runtime: %w\", err)\n\t}\n\tresult[\"id\"] = runtimeID","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_runtime.go#L217-L253","documentation":"runRuntimeDelete first attempts client.DeleteJSON on /api/runtimes/{id}; on failure it inspects the error with runtimeDeleteConflict. This error is the non-conflict path: the DELETE failed for an ordinary reason (404 unknown runtime, 401/403, transport, decode) rather than the active-agents conflict, so it is re-wrapped as \"delete runtime: %w\".","triggerScenarios":"Deleting a runtime ID that does not exist (404); insufficient permission (403); expired token; server unreachable; a response shape that runtimeDeleteConflict cannot parse as a conflict (falling through to this branch).","commonSituations":"Runtime already deleted by another operator; stale ID from an old listing; read-only service accounts attempting deletion.","solutions":["Check the wrapped cause: 404 means it is already gone (nothing to do), 401/403 means re-auth or use an authorized account.","Refresh the ID via `multica runtime list` and retry if it was a stale reference.","If the wrapped body looks like an agent-conflict but was not detected, compare CLI and server versions — the conflict payload format may have changed."],"exampleFix":"# before\nmultica runtime delete rt_123   # \"delete runtime: ... 404\"\n\n# after\nmultica runtime list              # confirm whether rt_123 still exists\nmultica runtime delete rt_9ab     # use current ID","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err = client.DeleteJSON(ctx, \"/api/runtimes/\"+runtimeID)\nif err != nil && !runtimeDeleteConflict(err) {\n\tvar status cli.HTTPStatusError\n\tif errors.As(err, &status) && status.Code == 404 {\n\t\treturn nil // already deleted: treat as success\n\t}\n\treturn fmt.Errorf(\"delete runtime: %w\", err)\n}","preventionTips":["Treat 404 on delete as idempotent success in automation.","Refresh runtime IDs from list output before deleting.","Ensure the account has delete permission before scripting decommissions."],"tags":["go","cli","http","delete","runtimes","api-client"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}