{"record":{"id":"caa007be05457863","repo":"hasura/graphql-engine","slug":"reading-global-config-file-failed-w","errorCode":null,"errorMessage":"reading global config file failed: %w","messagePattern":"reading global config file failed: %w","errorType":"exception","errorClass":"errors.Error","httpStatus":null,"severity":"error","filePath":"cli/global_config.go","lineNumber":181,"sourceCode":"\n\t\tec.Logger.Debugf(\n\t\t\t\"global config file written at '%s' with content '%v'\",\n\t\t\tec.GlobalConfigFile,\n\t\t\tgc,\n\t\t)\n\n\t\t// also show a notice about telemetry\n\t\tec.Logger.Info(TelemetryNotice)\n\t} else if stderrors.Is(err, fs.ErrExist) || err == nil {\n\t\t// file exists, verify contents\n\t\tec.Logger.Debug(\"global config file exists, verifying contents\")\n\n\t\t// initialize the config object\n\t\tgc := rawGlobalConfig{}\n\n\t\terr := gc.read(ec.GlobalConfigFile)\n\t\tif err != nil {\n\t\t\treturn errors.E(op, fmt.Errorf(\"reading global config file failed: %w\", err))\n\t\t}\n\n\t\t// validate keys\n\t\terr = gc.validateKeys()\n\t\tif err != nil {\n\t\t\treturn errors.E(op, fmt.Errorf(\"validating global config file failed: %w\", err))\n\t\t}\n\n\t\t// write the file if there are any changes\n\t\tif gc.shoudlWrite {\n\t\t\terr := gc.write(ec.GlobalConfigFile)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.E(op, fmt.Errorf(\"writing global config file failed: %w\", err))\n\t\t\t}\n\n\t\t\tec.Logger.Debugf(\n\t\t\t\t\"global config file written at '%s' with content '%+#v'\",\n\t\t\t\tec.GlobalConfigFile,","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/global_config.go#L163-L199","documentation":"An existing global config file was found, but gc.read(ec.GlobalConfigFile) failed to parse it. This is a malformed config file: invalid YAML/JSON syntax, wrong types for fields, or a file that cannot be opened (permission/chmod). The wrapped error usually carries the parse position.","triggerScenarios":"Manually editing ~/.<app>/config.<ext> and introducing a syntax error (tab indentation in YAML, missing quote, trailing comma in JSON), or another tool overwriting the file with garbage.","commonSituations":"Hand-edited config after following online tutorials, secrets-injection tools mangling YAML, config managed by Helm/sed substitutions producing invalid syntax, or a truncated file from a crashed write.","solutions":["Validate the file syntax with a YAML/JSON linter and fix the reported line/column","Restore from a backup or delete the file to let the CLI regenerate defaults","Check for tabs vs spaces if YAML (tabs are illegal for indentation)","If types matter, ensure values match expected types (strings quoted when needed)"],"exampleFix":"# before (config.yaml)\nuuid: my-uuid\ncli_environment: dev\n  extra_tab: oops\n# after\nuuid: my-uuid\ncli_environment: dev","handlingStrategy":"validation","validationCode":"if b, err := os.ReadFile(ec.GlobalConfigFile); err == nil {\n    var probe map[string]any\n    if err := yaml.Unmarshal(b, &probe); err != nil {\n        return fmt.Errorf(\"config file is malformed, fix or delete %s: %w\", ec.GlobalConfigFile, err)\n    }\n}","typeGuard":"func configParses(path string) bool {\n    b, err := os.ReadFile(path)\n    if err != nil {\n        return false\n    }\n    var m map[string]any\n    return yaml.Unmarshal(b, &m) == nil\n}","tryCatchPattern":"if err := ec.Prepare(ctx); err != nil {\n    if strings.Contains(err.Error(), \"reading global config file failed\") {\n        bak := ec.GlobalConfigFile + \".bak\"\n        _ = os.Rename(ec.GlobalConfigFile, bak)\n        return ec.Prepare(ctx) // regenerates defaults\n    }\n    return err\n}","preventionTips":["Validate config edits with a YAML/JSON linter before running","Use spaces (never tabs) in YAML config","Keep backups before automated config edits"],"tags":["go","config","yaml","parse-error","user-input"],"backgroundTag":"config-file-parse-error","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}