AdguardTeam/AdGuardHome · error
bad value for %q key: %w
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.
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)
Solutions
- Fetch the version.json URL manually and inspect all keys for empty values
- Fix the publishing pipeline so every key has a non-empty string (use a placeholder like '-' for announcement)
- Switch to the default/stable update channel or official metadata URL
- 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
- Validate version.json with a schema before feeding it to the updater
- Monitor channel metadata generation so no key ships empty
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.
Related errors
- constructing request to %s: %w
- sending http request to %s: %w
- got status code %d, want %d
- reading response from %s: %w
- version.json: %w
AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27).
Data as JSON: /api/errors/6e35bddcf956ece5.
Report an issue: GitHub.