{"record":{"id":"a8c7562ab2c05720","repo":"openfaas/faas","slug":"unknown-log-request-error-v","errorCode":null,"errorMessage":"unknown log request error (%v)","messagePattern":"unknown log request error \\((.+?)\\)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"gateway/handlers/logs.go","lineNumber":88,"sourceCode":"\t\tswitch logResp.StatusCode {\n\t\tcase http.StatusNotFound, http.StatusNotImplemented:\n\t\t\tw.WriteHeader(http.StatusNotImplemented)\n\t\t\treturn\n\t\tcase http.StatusOK:\n\t\t\t// watch for connection closures and stream data\n\t\t\t// connections and contexts should have cancel methods deferred already\n\t\t\tselect {\n\t\t\tcase err := <-copyNotify(&unbufferedWriter{wf}, logResp.Body):\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Printf(\"LogProxy: error while copy: %s\", err.Error())\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\tcase <-cn.CloseNotify():\n\t\t\t\tlog.Printf(\"LogProxy: client connection closed\")\n\t\t\t\treturn\n\t\t\t}\n\t\tdefault:\n\t\t\thttp.Error(w, fmt.Sprintf(\"unknown log request error (%v)\", logResp.StatusCode), http.StatusInternalServerError)\n\t\t}\n\n\t\treturn\n\t}\n}\n\ntype writerFlusher interface {\n\tio.Writer\n\thttp.Flusher\n}\n\n// unbufferedWriter is an io Writer that immediately flushes the after every call to Write.\n// This can wrap any http.ResponseWriter that also implements Flusher.  This ensures that log\n// lines are immediately sent to the client\ntype unbufferedWriter struct {\n\tdst writerFlusher\n}\n","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/openfaas/faas/blob/8d803bf9e2655aec6a60fd0e25b392839f96af95/gateway/handlers/logs.go#L70-L106","documentation":"After forwarding a log request to the provider, the handler in gateway/handlers/logs.go switches on the response status: 200 streams log output, and 404/501 map to 501 Not Implemented (provider has no log API). Any other status falls into the default branch and is returned as 500 with 'unknown log request error (CODE)'. The provider's original status code is embedded in the message, so it tells you exactly what came back.","triggerScenarios":"The provider replies to /system/logs with an unexpected status: 500 from an internal error, 401/403 when auth (basic auth, mTLS) rejects the gateway, 429 under throttling, or 502/503 from a load balancer sitting between gateway and provider.","commonSituations":"Provider crashing while opening the log stream; auth credentials rotated on one side only; an ingress/LB returning 503 during health-check failures; provider versions that implement the endpoint but error for the requested function.","solutions":["Read the status code in parentheses of the error body — it is the provider's actual response code","Inspect the provider logs for the failing /system/logs request","If the code is 401/403, align auth credentials between gateway and provider","If 502/503, check any load balancer or service mesh between the components","Confirm the provider version implements container logs — 404/501 are handled gracefully, other codes are not"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# expect 200, 404 or 501; anything else indicates misconfiguration\nstatus=$(curl -s -o /dev/null -w '%{http_code}' \"$PROVIDER/system/logs?name=$FN\")\ncase \"$status\" in\n  200|404|501) ;;\n  *) echo \"unexpected provider status $status\" ;;\nesac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run a provider version that implements the logs API","Align auth between gateway and provider so log requests never come back 401/403","When an unknown status appears, the offending code is always embedded in the error text — start there"],"tags":["http","status-code","logging","provider"],"backgroundTag":null,"analyzedSha":"8d803bf9e2655aec6a60fd0e25b392839f96af95","analyzedAt":"2026-08-16T00:12:29.759Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}