{"record":{"id":"30af53d211c20a92","repo":"multica-ai/multica","slug":"get-runtime-activity-w","errorCode":null,"errorMessage":"get runtime activity: %w","messagePattern":"get runtime activity: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_runtime.go","lineNumber":195,"sourceCode":"\t\t\tstrVal(u, \"cache_write_tokens\"),\n\t\t})\n\t}\n\tcli.PrintTable(os.Stdout, headers, rows)\n\treturn nil\n}\n\nfunc runRuntimeActivity(cmd *cobra.Command, args []string) error {\n\tclient, err := newAPIClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tctx, cancel := cli.APIContext(context.Background())\n\tdefer cancel()\n\n\tvar activity []map[string]any\n\tif err := client.GetJSON(ctx, \"/api/runtimes/\"+args[0]+\"/activity\", &activity); err != nil {\n\t\treturn fmt.Errorf(\"get runtime activity: %w\", err)\n\t}\n\n\toutput, _ := cmd.Flags().GetString(\"output\")\n\tif output == \"json\" {\n\t\treturn cli.PrintJSON(os.Stdout, activity)\n\t}\n\n\theaders := []string{\"HOUR\", \"COUNT\"}\n\trows := make([][]string, 0, len(activity))\n\tfor _, a := range activity {\n\t\trows = append(rows, []string{\n\t\t\tstrVal(a, \"hour\"),\n\t\t\tstrVal(a, \"count\"),\n\t\t})\n\t}\n\tcli.PrintTable(os.Stdout, headers, rows)\n\treturn nil\n}","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_runtime.go#L177-L213","documentation":"runRuntimeActivity wraps a failed client.GetJSON to GET /api/runtimes/{args[0]}/activity, which returns hourly activity buckets for a runtime. Same failure family as 654/656: transport error, 401/403/404, or decode failure on the []map[string]any result. The ID is interpolated unescaped, so malformed IDs yield route misses.","triggerScenarios":"Nonexistent or deleted runtime ID (404); no auth or expired token; server without the activity endpoint (older version, 404); unreachable server.","commonSituations":"Querying activity for a runtime that aged out or was deleted; CLI newer than the deployed server; wrong environment's credentials.","solutions":["Verify the runtime ID exists right now with `multica runtime list`.","Re-authenticate / verify base URL if the wrapped error mentions 401 or connection failure.","Align CLI and server versions if /activity is missing on the server."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := client.GetJSON(ctx, \"/api/runtimes/\"+args[0]+\"/activity\", &activity); err != nil {\n\t// 404 can mean unknown runtime OR missing endpoint on old servers; check /api/runtimes first\n\treturn fmt.Errorf(\"get runtime activity: %w\", err)\n}","preventionTips":["Confirm the runtime exists via list before querying activity.","Keep server version >= the one that introduced /activity.","Reuse one authenticated client for all runtime queries in a script."],"tags":["go","cli","http","runtimes","activity","api-client"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}