{"record":{"id":"34faface5a25f1f5","repo":"amir20/dozzle","slug":"failed-to-save-config-w","errorCode":null,"errorMessage":"failed to save config: %w","messagePattern":"failed to save config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/support/cli/agent_command.go","lineNumber":68,"sourceCode":"func (h *persistingNotificationHandler) HandleNotificationConfig(subscriptions []types.SubscriptionConfig, dispatchers []types.DispatcherConfig) error {\n\t// Update the manager\n\tif err := h.manager.HandleNotificationConfig(subscriptions, dispatchers); err != nil {\n\t\treturn err\n\t}\n\n\t// Save to disk\n\tif err := os.MkdirAll(\"./data\", 0755); err != nil {\n\t\treturn fmt.Errorf(\"failed to create data directory: %w\", err)\n\t}\n\n\tfile, err := os.Create(h.configPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create config file: %w\", err)\n\t}\n\tdefer file.Close()\n\n\tif err := h.manager.WriteConfig(file); err != nil {\n\t\treturn fmt.Errorf(\"failed to save config: %w\", err)\n\t}\n\n\tlog.Debug().Str(\"path\", h.configPath).Msg(\"Saved notification config to disk\")\n\treturn nil\n}\n\n// SetCloudStreamLogs applies the hub's log-streaming choice to this agent's own\n// cloud client. The agent streams its logs to cloud itself rather than through\n// the hub, so without this a user who turned streaming off saw it stop on the\n// hub while every agent kept sending.\nfunc (h *persistingNotificationHandler) SetCloudStreamLogs(enabled *bool) {\n\tcc := h.cloudConfig.Load()\n\tif cc == nil {\n\t\treturn\n\t}\n\tupdated := *cc\n\tupdated.StreamLogs = enabled\n\th.cloudConfig.Store(&updated)","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/support/cli/agent_command.go#L50-L86","documentation":"After the file is created, the manager serializes the current subscriptions and dispatchers via WriteConfig(file). Any error during that write (marshal failure inside the manager, write syscall error, disk full) is wrapped with this message; the on-disk config may be partially written.","triggerScenarios":"h.manager.WriteConfig(file) returning an error: I/O failure while writing to the just-created file (ENOSPC, EIO) or a serialization problem inside the manager (e.g. unsupported dispatcher data).","commonSituations":"Disk filling up mid-write; network volume dropping; a dispatcher/subscription holding data that fails to serialize into the YAML output.","solutions":["Check the wrapped error: ENOSPC means free disk space; serialization errors mean inspect the config data","Verify disk space and mount health on the data volume","Delete the partial config file and retry the operation so a clean file is written","Update the client/manager if the wrapped error indicates a marshal bug in WriteConfig"],"exampleFix":"// before\n# disk full: WriteConfig fails mid-write, leaving truncated notifications.yml\n// after\n# df -h ./data && rm ./data/notifications.yml, then retry the save","handlingStrategy":"try-catch","validationCode":"if st, err := os.Stat(filepath.Dir(h.configPath)); err != nil || st == nil {\n    return fmt.Errorf(\"config dir missing\")\n}","typeGuard":null,"tryCatchPattern":"if err := h.manager.WriteConfig(file); err != nil {\n    file.Close()\n    os.Remove(h.configPath) // drop partial write\n    return err\n}","preventionTips":["Monitor free disk space on the data volume","Write to a temp file and rename for atomic config saves","Keep serializable data in subscriptions/dispatchers"],"tags":["filesystem","persistence","serialization"],"backgroundTag":"file-write-failed","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}