netbirdio/netbird · error

reading body failed with error

Error message

reading body failed with error: %v

What it means

Reading the response body from the device-authorization endpoint failed after a successful HTTP call (io.ReadAll error). Without the body the AuthFlowInfo (device code, verification URI, interval) cannot be decoded, so RequestAuthInfo fails and the device flow cannot proceed.

Solutions

  1. Retry the request
  2. Check for intermediary proxies truncating responses
  3. Verify IdP endpoint stability
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at client/internal/auth/device_flow.go:161 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/55eda6af9453ee22. Report an issue: GitHub.

Appendix: source

Thrown at client/internal/auth/device_flow.go:161

	form.Add("client_id", d.providerConfig.ClientID)
	form.Add("audience", d.providerConfig.Audience)
	form.Add("scope", d.providerConfig.Scope)
	req, err := http.NewRequest("POST", d.providerConfig.DeviceAuthEndpoint,
		strings.NewReader(form.Encode()))
	if err != nil {
		return AuthFlowInfo{}, fmt.Errorf("creating request failed with error: %v", err)
	}
	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

	res, err := d.HTTPClient.Do(req)
	if err != nil {
		return AuthFlowInfo{}, fmt.Errorf("doing request failed with error: %v", err)
	}

	defer res.Body.Close()
	body, err := io.ReadAll(res.Body)
	if err != nil {
		return AuthFlowInfo{}, fmt.Errorf("reading body failed with error: %v", err)
	}

	if res.StatusCode != 200 {
		return AuthFlowInfo{}, fmt.Errorf("request device code returned status %d error: %s", res.StatusCode, string(body))
	}

	deviceCode := AuthFlowInfo{}
	err = json.Unmarshal(body, &deviceCode)
	if err != nil {
		return AuthFlowInfo{}, fmt.Errorf("unmarshaling response failed with error: %v", err)
	}

	// Fallback to the verification_uri if the IdP doesn't support verification_uri_complete
	if deviceCode.VerificationURIComplete == "" {
		deviceCode.VerificationURIComplete = deviceCode.VerificationURI
	}

	if d.providerConfig.LoginHint != "" {

View on GitHub (pinned to 93e97f4bf1)