getsops/sops · error

unexpected status code: %d

Error message

unexpected status code: %d

What it means

Error "unexpected status code: %d" thrown in getsops/sops.

Source

Thrown at version/version.go:185

		// Follow HTTP 301 redirects, which may be present due to the
		// repository being renamed. But do not follow HTTP 302 redirects,
		// which is what GitHub uses to redirect to the latest release.
		if req.Response.StatusCode == 302 {
			return http.ErrUseLastResponse
		}
		return nil
	}

	resp, err := client.Head(fmt.Sprintf("%s/%s/releases/latest", f.endpoint, repository))
	if err != nil {
		return "", "", err
	}
	if resp.Body != nil {
		defer resp.Body.Close()
	}

	if resp.StatusCode < 300 || resp.StatusCode > 399 {
		return "", "", fmt.Errorf("unexpected status code: %d", resp.StatusCode)
	}

	location := resp.Header.Get("Location")
	if location == "" {
		return "", "", fmt.Errorf("missing Location header")
	}

	tagMarker := "releases/tag/"
	if tagIndex := strings.Index(location, tagMarker); tagIndex != -1 {
		return location[tagIndex+len(tagMarker):], location, nil
	}
	return "", "", fmt.Errorf("unexpected Location header: %s", location)
}

// LatestReleaseUsingAPI retrieves the most recent release version from the
// GitHub API. It returns the latest version as a string, along with its
// corresponding URL, or an error in case of request failure or parsing issues
// with the response.

View on GitHub (pinned to 13442bb981)

When it happens

Trigger: Thrown at version/version.go:185 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of getsops/sops@13442bb981 (2026-09-01). Data as JSON: /api/errors/489044395e54b13a. Report an issue: GitHub.