{"record":{"id":"f973e24d3b842793","repo":"multica-ai/multica","slug":"get-issue-usage-w","errorCode":null,"errorMessage":"get issue usage: %w","messagePattern":"get issue usage: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_issue.go","lineNumber":2157,"sourceCode":"}\n\nfunc runIssueUsage(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\tissueRef, err := resolveIssueRef(ctx, client, args[0])\n\tif err != nil {\n\t\treturn fmt.Errorf(\"resolve issue: %w\", err)\n\t}\n\n\tvar result map[string]any\n\tif err := client.GetJSON(ctx, \"/api/issues/\"+url.PathEscape(issueRef.ID)+\"/usage\", &result); err != nil {\n\t\treturn fmt.Errorf(\"get issue usage: %w\", err)\n\t}\n\n\toutput, _ := cmd.Flags().GetString(\"output\")\n\tif output == \"json\" {\n\t\treturn cli.PrintJSON(os.Stdout, result)\n\t}\n\n\t// JSON numbers decode to float64; formatMetadataValue renders them as clean\n\t// integers (no scientific notation for large cache-token counts).\n\theaders := []string{\"INPUT_TOKENS\", \"OUTPUT_TOKENS\", \"CACHE_READ\", \"CACHE_WRITE\", \"RUNS\"}\n\trows := [][]string{{\n\t\tformatMetadataValue(result[\"total_input_tokens\"]),\n\t\tformatMetadataValue(result[\"total_output_tokens\"]),\n\t\tformatMetadataValue(result[\"total_cache_read_tokens\"]),\n\t\tformatMetadataValue(result[\"total_cache_write_tokens\"]),\n\t\tformatMetadataValue(result[\"task_count\"]),\n\t}}\n\tcli.PrintTable(os.Stdout, headers, rows)","sourceCodeStart":2139,"sourceCodeEnd":2175,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_issue.go#L2139-L2175","documentation":"After resolving the issue, `multica issue usage` GETs /api/issues/{id}/usage (URL-escaped). This error wraps the fetch failing: server-side aggregation error, permission denial, removed issue, or transport problems.","triggerScenarios":"The usage endpoint 5xx-ing (e.g. aggregation over a huge run history); scope-limited tokens; issue deleted mid-command; network failure.","commonSituations":"Usage queries against issues with very many task runs; service accounts without usage read scope.","solutions":["Retry — usage aggregation failures are often transient.","Verify token scope covers the usage endpoint.","Check server logs/metrics if a specific issue consistently fails."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# bash: pre-flight auth and issue before usage\nmultica issue get \"$ISSUE\" >/dev/null 2>&1 || { echo \"issue/auth problem\" >&2; exit 2; }","typeGuard":null,"tryCatchPattern":"# bash: retry once on server-side aggregation hiccups\nmultica issue usage \"$ISSUE\" 2>/tmp/err || {\n  grep -qE '50[0-3]|timeout' /tmp/err && exec multica issue usage \"$ISSUE\"\n  cat /tmp/err >&2; exit 1;\n}","preventionTips":["Cache usage reports instead of hammering huge issues repeatedly.","Alert on per-issue usage failures to spot aggregation regressions."],"tags":["cli","http","api-client","usage"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}