{"record":{"id":"e56c48fbe5f0dd6c","repo":"AdguardTeam/AdGuardHome","slug":"preparing-w","errorCode":null,"errorMessage":"preparing: %w","messagePattern":"preparing: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/updater/updater.go","lineNumber":169,"sourceCode":"\n\t\tmu: &sync.RWMutex{},\n\t}\n}\n\n// Update performs the auto-update.  It returns an error if the update fails.\n// If firstRun is true, it assumes the configuration file doesn't exist.\nfunc (u *Updater) Update(ctx context.Context, firstRun bool) (err error) {\n\tu.mu.Lock()\n\tdefer u.mu.Unlock()\n\n\tu.logger.InfoContext(ctx, \"starting update\", \"first_run\", firstRun)\n\tdefer func() {\n\t\tu.logUpdateResult(ctx, err)\n\t}()\n\n\terr = u.prepare(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"preparing: %w\", err)\n\t}\n\n\tdefer u.clean(ctx)\n\n\terr = u.downloadPackageFile(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"downloading package file: %w\", err)\n\t}\n\n\terr = u.unpack(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unpacking: %w\", err)\n\t}\n\n\tif !firstRun {\n\t\terr = u.check(ctx)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"checking config: %w\", err)","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/updater/updater.go#L151-L187","documentation":"Wraps any failure of the preparation step of the self-update flow: computing the update directory, validating the package URL, and stat-ing the current executable. The underlying error tells which sub-check failed.","triggerScenarios":"Calling Updater.Update with a packageURL whose path basename is empty, or when os.Stat on the current executable path fails (moved/deleted binary, wrong exec path config).","commonSituations":"Running from a deleted or replaced binary; misconfigured workDir/exec path; package URL ending in '/' so filepath.Split yields an empty filename.","solutions":["Check the wrapped error to see if it's 'invalid PackageURL' or 'checking %q'","Verify the current executable exists and the process has permission to stat it","Ensure packageURL points to a real file name, not a directory","Fix or recreate the configured binary path/workDir"],"exampleFix":"// before\nu.packageURL = \"https://example.com/dl/\"\n// after\nu.packageURL = \"https://example.com/dl/AdGuardHome_linux_amd64.tar.gz\"","handlingStrategy":"validation","validationCode":"if _, base := filepath.Split(u.packageURL); base == \"\" { /* fix URL first */ }\nif _, err := os.Stat(u.execPath); err != nil { /* fix exec path first */ }","typeGuard":null,"tryCatchPattern":"if err := u.Update(ctx); err != nil {\n    if strings.HasPrefix(err.Error(), \"preparing:\") { /* inspect wrapped cause: URL or stat */ }\n}","preventionTips":["Sanitize packageURL before every Update call","Verify the binary path at service startup"],"tags":["self-update","filesystem","updater"],"backgroundTag":"self-update-preparation-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}