{"record":{"id":"b988de9ccd986ccd","repo":"router-for-me/CLIProxyAPI","slug":"count-must-be-a-positive-integer","errorCode":null,"errorMessage":"count must be a positive integer","messagePattern":"count must be a positive integer","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/api/handlers/management/usage.go","lineNumber":52,"sourceCode":"\t}\n\n\titems := redisqueue.PopOldest(count)\n\trecords := make([]usageQueueRecord, 0, len(items))\n\tfor _, item := range items {\n\t\trecords = append(records, usageQueueRecord(append([]byte(nil), item...)))\n\t}\n\n\tc.JSON(http.StatusOK, records)\n}\n\nfunc parseUsageQueueCount(value string) (int, error) {\n\tvalue = strings.TrimSpace(value)\n\tif value == \"\" {\n\t\treturn 1, nil\n\t}\n\tcount, errCount := strconv.Atoi(value)\n\tif errCount != nil || count <= 0 {\n\t\treturn 0, errors.New(\"count must be a positive integer\")\n\t}\n\treturn count, nil\n}\n","sourceCodeStart":34,"sourceCodeEnd":56,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/api/handlers/management/usage.go#L34-L56","documentation":"The host.model.execute_stream callback explicitly requires the stream flag to be true. The RPC handler checks req.Stream after decoding and rejects non-streaming executions because this callback only manages streaming model bridges; non-streaming execution must use the non-stream callback.","triggerScenarios":"A plugin calls host.model.execute_stream with \"stream\": false or omits the field (Go zero value false) in HostModelExecutionRequest.","commonSituations":"Plugin developer copies the request struct from a non-streaming example and forgets to set Stream=true; default value of the bool field silently disabling streaming; plugin built against an SDK where the field was optional or implicit.","solutions":["Set Stream: true on the HostModelExecutionRequest before invoking host.model.execute_stream.","If you do not want streaming, call the non-streaming host.model.execute callback instead."],"exampleFix":"// before\nreq := pluginapi.HostModelExecutionRequest{Model: \"gpt-4o\", Input: input}\nhost.Call(ctx, \"host.model.execute_stream\", mustMarshal(req)) // error: requires stream=true\n\n// after\nreq := pluginapi.HostModelExecutionRequest{Model: \"gpt-4o\", Input: input, Stream: true}\nhost.Call(ctx, \"host.model.execute_stream\", mustMarshal(req))","handlingStrategy":"validation","validationCode":"if !req.Stream {\n    req.Stream = true // or route to the non-streaming host.model.execute callback instead\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"requires stream=true\") {\n    req.Stream = true\n    // re-issue once with the corrected flag\n}","preventionTips":["Set Stream:true at construction of any request passed to host.model.execute_stream.","Wrap the call in a helper that asserts Stream before dispatch.","Use the non-streaming callback for one-shot executions."],"tags":["pluginhost","validation","streaming"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}