matryer/xbar · error

marshal

Error message

marshal

What it means

Raised in Updater.getLatestRelease when json.Unmarshal cannot decode the downloaded release response body into the Release struct — the endpoint returned HTML (e.g. a proxy or error page), a truncated document, or a JSON schema that does not match the struct. The bytes were read successfully but do not represent a valid release object.

Source

Thrown at pkg/update/update.go:130

// getLatestRelease gets the latest release.
func (u *Updater) getLatestRelease() (*Release, error) {
	resp, err := u.Client.Get(u.LatestReleaseGitHubEndpoint)
	if err != nil {
		return nil, errors.Wrap(err, "get latest release")
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		return nil, errors.Errorf("failed to check for updates: got %s", resp.Status)
	}
	b, err := io.ReadAll(io.LimitReader(resp.Body, u.DownloadBytesLimit))
	if err != nil {
		return nil, errors.Wrap(err, "read body")
	}
	var latestRelease Release
	err = json.Unmarshal(b, &latestRelease)
	if err != nil {
		return nil, errors.Wrap(err, "marshal")
	}
	latestRelease.CreatedAt, err = time.Parse(time.RFC3339Nano, latestRelease.CreatedAtString)
	if err != nil {
		return nil, errors.Wrap(err, "time.Parse: created_at")
	}
	return &latestRelease, nil
}

// HasUpdate checks whether there's an update or not.
func (u *Updater) HasUpdate() (*Release, bool, error) {
	latest, err := u.getLatestRelease()
	if err != nil {
		return nil, false, err
	}
	hasUpdate := hasUpdate(u.CurrentVersion, latest.TagName)
	return latest, hasUpdate, nil
}

View on GitHub (pinned to d624239058)

Solutions

  1. Log or inspect the raw body to see what was actually returned (often an HTML error or auth page instead of JSON)
  2. Verify the endpoint is the GitHub API releases URL, not an HTML page redirected by a proxy or captive portal
  3. Check that the Release struct fields/tags match the current GitHub API response schema
  4. Retry, as a truncated download can also produce invalid JSON
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/update/update.go:130 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of matryer/xbar@d624239058 (2026-09-02). Data as JSON: /api/errors/50d3402ca2129dd2. Report an issue: GitHub.