{"record":{"id":"78990b0ec91c3119","repo":"matryer/xbar","slug":"open","errorCode":null,"errorMessage":"Open","messagePattern":"Open","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/plugins/variables.go","lineNumber":42,"sourceCode":"\t}\n\tfilename := filepath.Join(pluginDir, installedPluginPath+variableJSONFileExt)\n\terr = ioutil.WriteFile(filename, b, 0666)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"WriteFile\")\n\t}\n\treturn nil\n}\n\n// LoadVariableValues loads the variables for a plugin.\nfunc LoadVariableValues(pluginDir, installedPluginPath string) (map[string]interface{}, error) {\n\tfilename := filepath.Join(pluginDir, installedPluginPath+variableJSONFileExt)\n\tf, err := os.Open(filename)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\t// no file - but not an error, just empty map\n\t\t\treturn map[string]interface{}{}, nil\n\t\t}\n\t\treturn nil, errors.Wrap(err, \"Open\")\n\t}\n\tdefer f.Close()\n\tb, err := io.ReadAll(io.LimitReader(f, 1_000_000 /* ~1MB */))\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"ReadAll\")\n\t}\n\tvar values map[string]interface{}\n\terr = json.Unmarshal(b, &values)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"json.Unmarshal\")\n\t}\n\treturn values, nil\n}\n\nfunc (p *Plugin) loadVariablesAsEnvVars() ([]string, error) {\n\tvars, err := p.loadVariables()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"loadVariables\")","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/pkg/plugins/variables.go#L24-L60","documentation":"LoadVariableValues (pkg/plugins/variables.go:36-42) opens <pluginDir>/<installedPluginPath>.vars.json and wraps any os.Open failure other than 'not exists' with the message 'Open'. A missing file is intentionally treated as an empty map, so this error means the file exists but cannot be opened (permissions, path is a directory, I/O error). It surfaces as 'Open: <os error>'.","triggerScenarios":"The .vars.json path exists but is a directory; read permission denied on the file or a parent directory; the path contains invalid characters; SELinux/AppArmor denies access; the file lives on a failed/unmounted mount.","commonSituations":"Backup/sync tools (Dropbox, iCloud) replace the vars file with a placeholder directory; the user ran xbar once as root and the file is now root-owned with 0600; a broken symlink points to an inaccessible target.","solutions":["Run `ls -la` on the .vars.json path to check whether it is a directory, symlink, or has bad permissions.","Fix ownership/permissions: chown to the xbar user and chmod 600 the file.","Remove and re-create the vars file via the plugin settings UI if it is corrupt or a placeholder.","Check ACLs/mandatory access control (getfacl, audit logs) if permissions look correct but access still fails."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"info, err := os.Stat(filepath.Join(pluginDir, installedPluginPath+\".vars.json\"))\nswitch {\ncase os.IsNotExist(err):\n\t// fine — LoadVariableValues returns an empty map\ncase err != nil:\n\t// stat error, likely same cause as Open failure\n\tlog.Printf(\"vars path problem: %v\", err)\ncase info.IsDir():\n\tlog.Printf(\"%s is a directory, not a vars file\", info.Name())\ncase info.Mode().Perm()&0400 == 0:\n\tlog.Printf(\"vars file is not readable\")\n}","typeGuard":null,"tryCatchPattern":"values, err := plugins.LoadVariableValues(pluginDir, installedPluginPath)\nif err != nil {\n\tif strings.Contains(err.Error(), \"Open\") && errors.Is(errors.Cause(err), fs.ErrPermission) {\n\t\tvalues = map[string]interface{}{} // degrade to defaults\n\t} else {\n\t\treturn err\n\t}\n}","preventionTips":["Run xbar as a single consistent user so files are not root-owned.","Exclude the plugins directory from sync tools that create placeholder dirs.","Check readability of *.vars.json after restoring from backups.","Keep ACLs on the plugin dir simple (no restrictive ACLs)."],"tags":["go","filesystem","file-open","permissions"],"backgroundTag":"file-open-permission-denied","analyzedSha":"d624239058997c80118eaebe2e7f8331b3c765e0","analyzedAt":"2026-09-02T22:38:22.007Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}