{"record":{"id":"a1750451b7689704","repo":"AdguardTeam/AdGuardHome","slug":"version-json-w","errorCode":null,"errorMessage":"version.json: %w","messagePattern":"version\\.json: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/updater/check.go","lineNumber":104,"sourceCode":"}\n\n// parseVersionResponse parses version-related data and unmarshals it into the\n// [VersionInfo] structure.\nfunc (u *Updater) parseVersionResponse(\n\tctx context.Context,\n\tdata []byte,\n) (vi VersionInfo, err error) {\n\tinfo := VersionInfo{\n\t\tCanAutoUpdate: aghalg.NBFalse,\n\t}\n\tversionJSON := map[string]string{\n\t\t\"version\":          \"\",\n\t\t\"announcement\":     \"\",\n\t\t\"announcement_url\": \"\",\n\t}\n\terr = json.Unmarshal(data, &versionJSON)\n\tif err != nil {\n\t\treturn info, fmt.Errorf(\"version.json: %w\", err)\n\t}\n\n\tfor k, v := range versionJSON {\n\t\terr = validate.NotEmpty(\"version_json_value\", v)\n\t\tif err != nil {\n\t\t\treturn info, fmt.Errorf(\"bad value for %q key: %w\", k, err)\n\t\t}\n\t}\n\n\tinfo.NewVersion = versionJSON[\"version\"]\n\tinfo.Announcement = versionJSON[\"announcement\"]\n\tinfo.AnnouncementURL = versionJSON[\"announcement_url\"]\n\n\tpackageURL, key, found := u.downloadURL(ctx, versionJSON)\n\tif !found {\n\t\treturn info, fmt.Errorf(\"version.json: bad key %q: %w\", key, errors.ErrNoValue)\n\t}\n","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/updater/check.go#L86-L122","documentation":"The downloaded version.json body failed to parse as the expected JSON object of string values; the json.Unmarshal error is wrapped as 'version.json: %w'.","triggerScenarios":"VersionInfo receiving a body that is not valid JSON or does not match map[string]string semantics (numbers, nested objects), e.g. an HTML error page served with 200.","commonSituations":"Update server misconfigured to serve HTML/markdown, a redirected login page, or a newer schema with non-string fields.","solutions":["Fetch the URL with curl and validate the JSON shape (flat object of strings)","Fix the hosted version.json to the expected format","If a redirect serves wrong content, correct the URL to the final endpoint"],"exampleFix":"// before (served)\n{\"version\": 1.2}\n// after\n{\"version\": \"v1.2.0\", \"announcement\": \"\", \"announcement_url\": \"\"}","handlingStrategy":"type-guard","validationCode":"var probe map[string]string\nif err := json.Unmarshal(body, &probe); err != nil { return fmt.Errorf(\"version.json not a flat string map\") }","typeGuard":"func isVersionJSON(b []byte) bool { var m map[string]string; return json.Unmarshal(b, &m) == nil }","tryCatchPattern":"info, err := u.VersionInfo(ctx)\nif err != nil && strings.Contains(err.Error(), \"version.json\") { /* endpoint serving wrong content; alert ops */ }","preventionTips":["Serve version.json with correct content-type and shape (flat string object)","Verify endpoint after hosting changes"],"tags":["updater","json","parsing"],"backgroundTag":"json-parse-error","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}