{"record":{"id":"623afec1a1e12bc7","repo":"hasura/graphql-engine","slug":"read-file-w","errorCode":null,"errorMessage":"read file: %w","messagePattern":"read file: %w","errorType":"exception","errorClass":"errors.Error","httpStatus":null,"severity":"error","filePath":"cli/global_config.go","lineNumber":55,"sourceCode":"\t// CLIEnvironment defines the environment the CLI is running\n\tCLIEnvironment Environment `json:\"cli_environment\"`\n}\n\ntype rawGlobalConfig struct {\n\tUUID                   *string     `json:\"uuid\"`\n\tEnableTelemetry        *bool       `json:\"enable_telemetry\"`\n\tShowUpdateNotification *bool       `json:\"show_update_notification\"`\n\tCLIEnvironment         Environment `json:\"cli_environment\"`\n\n\tshoudlWrite bool\n}\n\nfunc (c *rawGlobalConfig) read(filename string) error {\n\tvar op errors.Op = \"cli.rawGlobalConfig.read\"\n\n\tb, err := os.ReadFile(filename)\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"read file: %w\", err))\n\t}\n\n\terr = json.Unmarshal(b, c)\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"parse file %w\", err))\n\t}\n\n\treturn nil\n}\n\nfunc (c *rawGlobalConfig) validateKeys() error {\n\t// check prescence of uuid, create if doesn't exist\n\tif c.UUID == nil {\n\t\tuid := uuid.NewString()\n\t\tc.UUID = &uid\n\t\tc.shoudlWrite = true\n\t}\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/global_config.go#L37-L73","documentation":"rawGlobalConfig.read loads the global JSON config file with os.ReadFile; this error wraps any read failure such as not-exist or permission denied. It occurs during setupGlobalConfig, i.e. early in CLI startup when the per-user global configuration is loaded.","triggerScenarios":"setupGlobalConfig pointing at a global config path (e.g. ~/.config/tool/global.json) that does not exist, is unreadable due to permissions, or sits on an unavailable mount.","commonSituations":"First run of the tool before any global config was written; HOME/XDG_CONFIG_HOME unset or wrong in CI or cron; config file owned by root after sudo runs; broken symlinks.","solutions":["Run the tool's init/setup once so the global config is created, or create it manually with {}","Verify HOME and XDG_CONFIG_HOME are set correctly in the environment (cron, systemd, containers)","Fix ownership/permissions: ls -l on the config path, chown back to your user"],"exampleFix":"# before\n# ~/.config/tool/global.json missing\nmycli run\n# after\nmkdir -p ~/.config/tool && echo '{}' > ~/.config/tool/global.json && mycli run","handlingStrategy":"validation","validationCode":"path := configPath() // e.g. ~/.config/tool/global.json\nif _, err := os.Stat(path); err != nil {\n    if stderrors.Is(err, fs.ErrNotExist) {\n        _ = os.MkdirAll(filepath.Dir(path), 0o755)\n        _ = os.WriteFile(path, []byte(\"{}\"), 0o644)\n    } else {\n        log.Fatalf(\"cannot read global config: %v\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := setupGlobalConfig(); err != nil {\n    var pathErr *os.PathError\n    if stderrors.As(err, &pathErr) && stderrors.Is(pathErr, fs.ErrNotExist) {\n        // first run: create defaults and retry\n    }\n}","preventionTips":["Ship a default global config in container/CI images","Set HOME and XDG_CONFIG_HOME explicitly in cron and systemd units","Never run the tool under sudo when it writes user config"],"tags":["config","filesystem","read-error","go"],"backgroundTag":"config-read-failure","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}