{"record":{"id":"b2eddc4b09e8232d","repo":"router-for-me/CLIProxyAPI","slug":"model-execution-failed-with-status-d","errorCode":null,"errorMessage":"model execution failed with status %d","messagePattern":"model execution failed with status (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pluginhost/host_callbacks.go","lineNumber":317,"sourceCode":"\t\tStream:                  req.Stream,\n\t\tBody:                    append([]byte(nil), req.Body...),\n\t\tHeaders:                 cloneHeader(req.Headers),\n\t\tQuery:                   cloneValues(req.Query),\n\t\tAlt:                     req.Alt,\n\t\tSkipInterceptorPluginID: skipPluginID,\n\t\tSkipRouterPluginID:      skipPluginID,\n\t}\n}\n\nfunc modelExecutionError(errMsg *interfaces.ErrorMessage) error {\n\tif errMsg == nil {\n\t\treturn nil\n\t}\n\tif errMsg.Error != nil {\n\t\treturn errMsg.Error\n\t}\n\tif errMsg.StatusCode > 0 {\n\t\treturn fmt.Errorf(\"model execution failed with status %d\", errMsg.StatusCode)\n\t}\n\treturn fmt.Errorf(\"model execution failed\")\n}\n\nfunc (h *Host) callHostLog(ctx context.Context, request []byte) ([]byte, error) {\n\tvar req rpcHostLogRequest\n\tif errUnmarshal := json.Unmarshal(request, &req); errUnmarshal != nil {\n\t\treturn nil, fmt.Errorf(\"decode host log request: %w\", errUnmarshal)\n\t}\n\tctx = h.resolveCallbackContext(req.HostCallbackID, ctx)\n\tmessage := strings.TrimSpace(req.Message)\n\tif message == \"\" {\n\t\tmessage = \"plugin log\"\n\t}\n\tfields := log.Fields{}\n\tfor key, value := range req.Fields {\n\t\tkey = strings.TrimSpace(key)\n\t\tif key != \"\" {","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/pluginhost/host_callbacks.go#L299-L335","documentation":"modelExecutionError converts an upstream execution result into an error when the executor returned an ErrorMessage with no Go error object but a positive HTTP status code. The %d is the upstream HTTP status (401, 429, 500, ...) of the nested model call requested via host.model.execute.","triggerScenarios":"A plugin's host.model.execute call where the upstream provider returned an error status: 401/403 from bad credentials, 429 from rate limiting, 5xx provider outages. The executor produced only a status code without a structured error.","commonSituations":"Expired or invalid API keys on the routed provider; rate limits hit because the plugin issues nested model calls on top of user traffic; upstream outage; model not available for the account.","solutions":["Map the status: 401/403 -> refresh or fix credentials for the provider; 429 -> slow down or reduce nested calls; 5xx -> retry with backoff or switch provider.","Check the host logs for the same request: the executor usually logs the upstream response body with more detail.","For plugins, cache or limit host.model.execute calls to avoid amplifying rate limits.","Verify the model name passed in the nested request exists on the target provider."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-flight credentials/quota before issuing nested model calls\nif !providerHasValidCredential(provider) {\n    return fmt.Errorf(\"skip nested call: provider %s credentials invalid\", provider)\n}","typeGuard":"func retryableModelStatus(statusCode int) bool {\n    return statusCode == 429 || statusCode >= 500\n}","tryCatchPattern":"resp, err := host.ModelExecute(ctx, req)\nif err != nil {\n    if status, ok := extractStatus(err); ok { // parse \"failed with status %d\"\n        if status == 401 || status == 403 {\n            return refreshCredentialsAndRetry(ctx, req)\n        }\n        if status == 429 || status >= 500 {\n            return backoffRetry(ctx, req, 3)\n        }\n    }\n    return err\n}","preventionTips":["Cache host.model.execute results in plugins to avoid redundant upstream calls.","Keep provider credentials fresh and rotate before expiry (401s).","Respect Retry-After on 429 and add jittered backoff for 5xx."],"tags":["plugin","host-callback","upstream","http-status","pluginhost"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}