{"record":{"id":"cb351f35a28f5728","repo":"netbirdio/netbird","slug":"authentication-service-unavailable","errorCode":null,"errorMessage":"authentication service unavailable","messagePattern":"authentication service unavailable","errorType":"http","errorClass":null,"httpStatus":502,"severity":"error","filePath":"proxy/internal/auth/middleware.go","lineNumber":472,"sourceCode":"func (mw *Middleware) tryHeaderScheme(w http.ResponseWriter, r *http.Request, host string, config DomainConfig, hdr Header, next http.Handler) bool {\n\ttoken, _, err := hdr.Authenticate(r)\n\tif err != nil {\n\t\treturn mw.handleHeaderAuthError(w, r, err)\n\t}\n\tif token == \"\" {\n\t\treturn false\n\t}\n\n\tresult, err := mw.validateSessionToken(r.Context(), host, token, config.SessionPublicKey, auth.MethodHeader)\n\tif err != nil {\n\t\tsetHeaderCapturedData(r.Context(), \"\", \"\", nil, nil)\n\t\tstatus := http.StatusBadRequest\n\t\tmsg := \"invalid session token\"\n\t\tif errors.Is(err, errValidationUnavailable) {\n\t\t\tstatus = http.StatusBadGateway\n\t\t\tmsg = \"authentication service unavailable\"\n\t\t}\n\t\thttp.Error(w, msg, status)\n\t\treturn true\n\t}\n\n\tif !result.Valid {\n\t\tsetHeaderCapturedData(r.Context(), result.UserID, result.UserEmail, result.Groups, result.GroupNames)\n\t\thttp.Error(w, \"Unauthorized\", http.StatusUnauthorized)\n\t\treturn true\n\t}\n\n\tsetSessionCookie(w, token, config.SessionExpiration)\n\tif cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {\n\t\tcd.SetUserID(result.UserID)\n\t\tcd.SetUserEmail(result.UserEmail)\n\t\tcd.SetUserGroups(result.Groups)\n\t\tcd.SetUserGroupNames(result.GroupNames)\n\t\tcd.SetAuthMethod(auth.MethodHeader.String())\n\t}\n","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/proxy/internal/auth/middleware.go#L454-L490","documentation":"Sentinel-based branch in forwardWithHeaderAuth: validateSessionToken failed with errValidationUnavailable, meaning the error is infrastructural — the validation backend (key/service needed to verify session tokens) is unavailable — rather than the token being bad. Surfaced to the client as 502 Bad Gateway so callers know to retry rather than re-authenticate.","triggerScenarios":"Thrown at proxy/internal/auth/middleware.go:472 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the request after a short delay; the condition is expected to be transient","Check the health of the session-token validation service or key source the proxy depends on","Inspect proxy logs for the underlying error that produced errValidationUnavailable","If persistent, restart the proxy or restore the backing service before clients can authenticate"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","contentChangedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}