{"record":{"id":"067fa29c949f0fd2","repo":"netbirdio/netbird","slug":"unmarshaling-response-failed-with-error-v","errorCode":null,"errorMessage":"unmarshaling response failed with error: %v","messagePattern":"unmarshaling response failed with error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/internal/auth/device_flow.go","lineNumber":171,"sourceCode":"\tres, err := d.HTTPClient.Do(req)\n\tif err != nil {\n\t\treturn AuthFlowInfo{}, fmt.Errorf(\"doing request failed with error: %v\", err)\n\t}\n\n\tdefer res.Body.Close()\n\tbody, err := io.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn AuthFlowInfo{}, fmt.Errorf(\"reading body failed with error: %v\", err)\n\t}\n\n\tif res.StatusCode != 200 {\n\t\treturn AuthFlowInfo{}, fmt.Errorf(\"request device code returned status %d error: %s\", res.StatusCode, string(body))\n\t}\n\n\tdeviceCode := AuthFlowInfo{}\n\terr = json.Unmarshal(body, &deviceCode)\n\tif err != nil {\n\t\treturn AuthFlowInfo{}, fmt.Errorf(\"unmarshaling response failed with error: %v\", err)\n\t}\n\n\t// Fallback to the verification_uri if the IdP doesn't support verification_uri_complete\n\tif deviceCode.VerificationURIComplete == \"\" {\n\t\tdeviceCode.VerificationURIComplete = deviceCode.VerificationURI\n\t}\n\n\tif d.providerConfig.LoginHint != \"\" {\n\t\tdeviceCode.VerificationURIComplete = appendLoginHint(deviceCode.VerificationURIComplete, d.providerConfig.LoginHint)\n\t\tif deviceCode.VerificationURI != \"\" {\n\t\t\tdeviceCode.VerificationURI = appendLoginHint(deviceCode.VerificationURI, d.providerConfig.LoginHint)\n\t\t}\n\t}\n\n\treturn deviceCode, err\n}\n\nfunc appendLoginHint(uri, loginHint string) string {","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/internal/auth/device_flow.go#L153-L189","documentation":"Fires in RequestAuthInfo when json.Unmarshal cannot parse the device-authorization endpoint's 200 response into AuthFlowInfo. The IdP returned a 200 but the body is not valid JSON or lacks the expected fields (DeviceCode, UserCode, VerificationURI, etc.), indicating a non-conforming provider, an HTML error/interstitial page behind a 200, or a changed API shape.","triggerScenarios":"Thrown at client/internal/auth/device_flow.go:171 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Log the raw body to see what the IdP actually returned (HTML login page, proxy block page, or malformed JSON)","Confirm the endpoint is the correct device authorization URL from the IdP's .well-known/openid-configuration","Check for an intercepting proxy or captive portal returning non-JSON content with a 200 status","Update field mappings or provider handling if the IdP changed its response schema"],"exampleFix":null,"handlingStrategy":"fallback","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"}