{"record":{"id":"0d3d92724716fc74","repo":"mickael-kerjean/filestash","slug":"filestash-needs-to-be-able-to-create-and-edit-its","errorCode":null,"errorMessage":"Filestash needs to be able to create and edit its configuration, but it currently cannot. Change the permissions to allow writing to `%s`","messagePattern":"Filestash needs to be able to create and edit its configuration, but it currently cannot\\. Change the permissions to allow writing to `(.+?)`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/pkg/config/config_state.go","lineNumber":78,"sourceCode":"\t\t\t\tbreak\n\t\t\t}\n\t\t\tLog.Warning(\"common::config_state::load cannot decrypt config path '%s': %s\", jsonPathWithEncryptedData, err.Error())\n\t\t\tcontinue\n\t\t}\n\t\tval, err := sjson.Set(configStr, jsonPathWithEncryptedData, t)\n\t\tif err != nil {\n\t\t\tLog.Warning(\"common::config_state::load cannot put json value in config '%s': %s\", jsonPathWithEncryptedData, err.Error())\n\t\t\tcontinue\n\t\t}\n\t\tconfigStr = val\n\t}\n\treturn []byte(configStr), nil\n}\n\nfunc SaveConfig(v []byte) error {\n\tfile, err := os.OpenFile(GetAbsolutePath(CONFIG_PATH, \"config.json\"), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0660)\n\tif err != nil {\n\t\treturn fmt.Errorf(\n\t\t\tAPPNAME+\" needs to be able to create and edit its configuration, but it currently cannot. \"+\n\t\t\t\t\"Change the permissions to allow writing to `%s`\",\n\t\t\tGetAbsolutePath(CONFIG_PATH, \"config.json\"),\n\t\t)\n\t}\n\n\tconfigStr := string(v)\n\n\tvar (\n\t\tkey       = defaultValue(SECRET_KEY_DERIVATE_FOR_PROOF, \"CONFIG_SECRET\")\n\t\ttoEncrypt = defaultValue(true, \"CONFIG_ENCRYPT\")\n\t)\n\tfor _, jsonPathWithEncryptedData := range configKeysToEncrypt {\n\t\tif !toEncrypt {\n\t\t\tcontinue\n\t\t}\n\t\tp := gjson.Get(configStr, jsonPathWithEncryptedData).String()\n\t\tif p == \"\" {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/mickael-kerjean/filestash/blob/78f756eb94ef383f1f1cd4bc3077a43a4d088ff0/server/pkg/config/config_state.go#L60-L96","documentation":"Returned by SaveConfig when os.OpenFile on config.json (with O_WRONLY|O_CREATE|O_TRUNC, mode 0660) fails — typically EACCES/EPERM because the Filestash process user cannot write to its configuration directory, or the path is read-only. Config changes cannot be persisted until the write permission is fixed.","triggerScenarios":"Thrown at server/pkg/config/config_state.go:78 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["chown/chmod the config.json file and its directory so the Filestash process user has read-write access","Check for immutable flags (chattr +i), read-only mounts, or disk-full conditions","Run the server under a user with write access to the config path, or relocate CONFIG_PATH to a writable location","Verify after fix that Save() completes and config.json is updated"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"78f756eb94ef383f1f1cd4bc3077a43a4d088ff0","analyzedAt":"2026-09-06T11:52:48.712Z","contentChangedAt":"2026-09-06T11:52:48.712Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}