{"record":{"id":"834eb3737b3fc87d","repo":"AdguardTeam/AdGuardHome","slug":"writing-config-file-w","errorCode":null,"errorMessage":"writing config file: %w","messagePattern":"writing config file: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/home/config.go","lineNumber":922,"sourceCode":"\t}\n\n\tconfig.Clients.Persistent = globalContext.clients.forConfig()\n\n\tconfPath = configFilePath(ctx, l, workDir, confPath)\n\tl.DebugContext(ctx, \"writing config file\", \"path\", confPath)\n\n\tbuf := &bytes.Buffer{}\n\tenc := yaml.NewEncoder(buf)\n\tenc.SetIndent(2)\n\n\terr = enc.Encode(config)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"generating config file: %w\", err)\n\t}\n\n\terr = maybe.WriteFile(confPath, buf.Bytes(), aghos.DefaultPermFile)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"writing config file: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// validateTLSCipherIDs validates the custom TLS cipher suite IDs.\nfunc validateTLSCipherIDs(cipherIDs []string) (err error) {\n\tif len(cipherIDs) == 0 {\n\t\treturn nil\n\t}\n\n\t_, err = aghtls.ParseCiphers(cipherIDs)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"override_tls_ciphers: %w\", err)\n\t}\n\n\treturn nil\n}","sourceCodeStart":904,"sourceCodeEnd":940,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/home/config.go#L904-L940","documentation":"The YAML config was encoded successfully but could not be written to confPath — a filesystem-level failure from maybe.WriteFile (permissions, disk full, missing directory, read-only fs).","triggerScenarios":"Any config persistence operation (setup wizard completion, settings changes via API) when the process lacks write access to the config file path or the disk is full.","commonSituations":"Running as an unprivileged user, container with read-only config mount, full disk, file locked by another process on some platforms.","solutions":["Verify write permission on confPath for the service user (chown/chmod)","Free disk space; ensure the config directory exists and is writable","In containers, mount the config volume read-write","Restore disk/FS health if the wrapped error indicates I/O failure"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Preflight writability check\nif _, err := os.OpenFile(confPath, os.O_WRONLY, 0o644); err != nil {\n    return fmt.Errorf(\"config not writable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"// Treat as environmental: alert ops, keep running with current config\nif err != nil { alertOps(\"config write failed: %v\", err) }","preventionTips":["Mount config volumes read-write in containers","Monitor disk space on the config partition","Run service under a user owning the config file"],"tags":["config","filesystem","permissions","persistence"],"backgroundTag":"config-file-write-failure","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}