{"record":{"id":"1cdff441c7baf605","repo":"hasura/graphql-engine","slug":"parse-file-w","errorCode":null,"errorMessage":"parse file %w","messagePattern":"parse file %w","errorType":"exception","errorClass":"errors.Error","httpStatus":null,"severity":"error","filePath":"cli/global_config.go","lineNumber":60,"sourceCode":"\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\n\t// check enabletelemetry\n\tif c.EnableTelemetry == nil {\n\t\ttrueVal := true\n\t\tc.EnableTelemetry = &trueVal\n\t\tc.shoudlWrite = true","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/global_config.go#L42-L78","documentation":"After successfully reading the global config bytes, json.Unmarshal failed to parse them into rawGlobalConfig. This means the file exists and is readable but is not valid JSON or does not match the expected structure.","triggerScenarios":"setupGlobalConfig reading a global config file containing malformed JSON — trailing commas, comments, single quotes, truncation from a concurrent write, or a BOM/UTF-16 encoding.","commonSituations":"Hand-edited config with JSON5-style syntax; file truncated by a crashed write; editor saving with BOM; secrets injected into the file with unescaped characters; two processes writing simultaneously.","solutions":["Validate the file with a JSON linter: jq . ~/.config/tool/global.json and fix reported syntax errors","Restore from backup or regenerate via init if the file is truncated","Re-save without BOM and ensure UTF-8 encoding"],"exampleFix":"// before ({~/.config/tool/global.json})\n{ \"telemetry\": true, }  // trailing comma\n// after\n{ \"telemetry\": true }","handlingStrategy":"try-catch","validationCode":"b, err := os.ReadFile(configPath)\nif err == nil {\n    if !json.Valid(b) {\n        log.Fatalf(\"global config is not valid JSON; run: jq . %s\", configPath)\n    }\n}","typeGuard":"func isValidJSONConfig(b []byte) bool {\n    return json.Valid(b)\n}","tryCatchPattern":"if err := setupGlobalConfig(); err != nil {\n    var synErr *json.SyntaxError\n    if stderrors.As(err, &synErr) {\n        // report synErr.Offset to pinpoint the bad character, then fix or regenerate the file\n    }\n}","preventionTips":["Lint the config with jq after every manual edit","Write configs atomically (temp file + rename) to avoid truncation","Save as UTF-8 without BOM"],"tags":["config","json","parse-error","go"],"backgroundTag":"invalid-json-config","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}