AdguardTeam/AdGuardHome · error

bad value for key

Error message

bad value for %q key: %w

What it means

Thrown while parsing the version.json response during an update check. Each value in the JSON map must be a non-empty string; validate.NotEmpty rejects empty or whitespace-only values. The offending key name is included in the message.

Solutions

  1. Fetch the version.json URL manually and inspect all keys for empty values
  2. Fix the publishing pipeline so every key has a non-empty string (use a placeholder like '-' for announcement)
  3. Switch to the default/stable update channel or official metadata URL
  4. Retry later if the mirror content is transiently corrupted

Example fix

// before
{"version":"v0.107.0","announcement":"","announcement_url":"https://..."}
// after
{"version":"v0.107.0","announcement":"-","announcement_url":"https://..."}
Defensive patterns

Strategy: validation

Validate before calling

resp, err := http.Get(url)
// ...
var vj map[string]string
if err := json.NewDecoder(resp.Body).Decode(&vj); err != nil { /* handle */ }
for k, v := range vj {
    if strings.TrimSpace(v) == "" { /* skip/fix key before calling VersionInfo */ }
}

Try / catch

if _, err := u.VersionInfo(ctx); err != nil {
    if strings.Contains(err.Error(), "bad value for") { /* tolerate and use cached info */ }
}

Prevention

When it happens

Trigger: Calling VersionInfo/parseVersionResponse against a version.json whose 'version', 'announcement', or 'announcement_url' (or any other) key has an empty string value.

Common situations: Corrupted or truncated mirror serving version.json; a CI/staging channel where announcement fields are left blank; manual editing of the channel metadata.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27). Data as JSON: /api/errors/6e35bddcf956ece5. Report an issue: GitHub.

Appendix: source

Thrown at internal/updater/check.go:110

	data []byte,
) (vi VersionInfo, err error) {
	info := VersionInfo{
		CanAutoUpdate: aghalg.NBFalse,
	}
	versionJSON := map[string]string{
		"version":          "",
		"announcement":     "",
		"announcement_url": "",
	}
	err = json.Unmarshal(data, &versionJSON)
	if err != nil {
		return info, fmt.Errorf("version.json: %w", err)
	}

	for k, v := range versionJSON {
		err = validate.NotEmpty("version_json_value", v)
		if err != nil {
			return info, fmt.Errorf("bad value for %q key: %w", k, err)
		}
	}

	info.NewVersion = versionJSON["version"]
	info.Announcement = versionJSON["announcement"]
	info.AnnouncementURL = versionJSON["announcement_url"]

	packageURL, key, found := u.downloadURL(ctx, versionJSON)
	if !found {
		return info, fmt.Errorf("version.json: bad key %q: %w", key, errors.ErrNoValue)
	}

	isNewVersion := info.NewVersion != u.version
	if isNewVersion {
		u.logger.InfoContext(
			ctx,
			"a new version is available",
			"current_version", u.version,

View on GitHub (pinned to b41aefbe51)