{"record":{"id":"8419187bae592dd3","repo":"AdguardTeam/AdGuardHome","slug":"constructing-request-to-s-w","errorCode":null,"errorMessage":"constructing request to %s: %w","messagePattern":"constructing request to (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/updater/check.go","lineNumber":54,"sourceCode":"\n// VersionInfo downloads the latest version information.  If forceRecheck is\n// false and there are cached results, those results are returned.\nfunc (u *Updater) VersionInfo(ctx context.Context, forceRecheck bool) (vi VersionInfo, err error) {\n\tu.mu.Lock()\n\tdefer u.mu.Unlock()\n\n\tnow := time.Now()\n\trecheckTime := u.prevCheckTime.Add(versionCheckPeriod)\n\tif !forceRecheck && now.Before(recheckTime) {\n\t\tu.logger.DebugContext(ctx, \"version info recheck is not required yet\")\n\n\t\treturn u.prevCheckResult, u.prevCheckError\n\t}\n\n\tvcu := u.versionCheckURL\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, vcu, nil)\n\tif err != nil {\n\t\treturn VersionInfo{}, fmt.Errorf(\"constructing request to %s: %w\", vcu, err)\n\t}\n\n\tu.logger.DebugContext(ctx, \"requesting version data\", \"url\", vcu)\n\n\tresp, err := u.client.Do(req)\n\tif err != nil {\n\t\treturn VersionInfo{}, fmt.Errorf(\"sending http request to %s: %w\", vcu, err)\n\t}\n\tdefer func() { err = errors.WithDeferred(err, resp.Body.Close()) }()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn VersionInfo{}, fmt.Errorf(\n\t\t\t\"got status code %d, want %d\",\n\t\t\tresp.StatusCode,\n\t\t\thttp.StatusOK,\n\t\t)\n\t}\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/updater/check.go#L36-L72","documentation":"Updater.VersionInfo failed at http.NewRequestWithContext for the version-check URL; the URL is included in the message. This is a client-side request construction failure, not a network failure.","triggerScenarios":"Calling VersionInfo when the configured version check URL is malformed (bad scheme, control characters, unsupported protocol), or the context setup makes request construction fail.","commonSituations":"Broken/overridden update URL in config (typo, missing scheme), env-var-injected bad URL, or tests with placeholder URLs.","solutions":["Inspect the URL in the error message and fix the version-check URL configuration","Ensure the URL has a valid scheme and host (https://example.com/version.json)","Reset custom update-server overrides to defaults"],"exampleFix":"# before\nupdate_url: \"example.com/version.json\"\n# after\nupdate_url: \"https://example.com/version.json\"","handlingStrategy":"validation","validationCode":"u, err := url.Parse(checkURL)\nif err != nil || u.Scheme == \"\" || u.Host == \"\" { return fmt.Errorf(\"invalid update URL %q\", checkURL) }","typeGuard":"func validURL(s string) bool { u, err := url.Parse(s); return err == nil && u.IsAbs() && u.Host != \"\" }","tryCatchPattern":"info, err := u.VersionInfo(ctx)\nif err != nil { log.Printf(\"update check failed: %v\", err) }","preventionTips":["Validate configured update URLs at startup","Prefer documented defaults"],"tags":["updater","http","url","config"],"backgroundTag":"invalid-url","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}