{"record":{"id":"f5338f51dbc585bf","repo":"gastownhall/beads","slug":"parsing-central-config-s-w","errorCode":null,"errorMessage":"parsing central config %s: %w","messagePattern":"parsing central config (.+?): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configfile/central_config.go","lineNumber":47,"sourceCode":"\t}\n\treturn filepath.Join(home, \".config\", \"beads\", CentralConfigFileName)\n}\n\n// LoadCentralConfig reads the central server config from the given path.\n// Returns (nil, nil) if the file does not exist (graceful skip).\n// Returns an error only if the file exists but cannot be parsed.\nfunc LoadCentralConfig(path string) (*Config, error) {\n\tdata, err := os.ReadFile(path) // #nosec G304 - path from DefaultCentralConfigPath or env\n\tif os.IsNotExist(err) {\n\t\treturn nil, nil\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reading central config: %w\", err)\n\t}\n\n\tvar cfg Config\n\tif err := json.Unmarshal(data, &cfg); err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing central config %s: %w\", path, err)\n\t}\n\treturn &cfg, nil\n}\n\n// ApplyCentralDefaults merges server-related fields from the central config\n// into the per-project config, but only for fields that are at their zero\n// value in the project config. Non-server fields (Database, DoltDatabase,\n// DoltDataDir, ProjectID, etc.) are never inherited from the central config\n// because they are inherently per-project.\n//\n// This is a no-op if central is nil.\nfunc ApplyCentralDefaults(project *Config, central *Config) {\n\tif central == nil {\n\t\treturn\n\t}\n\n\t// Server connection fields only — these are the fields that are\n\t// typically identical across all projects on a machine.","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/configfile/central_config.go#L29-L65","documentation":"LoadCentralConfig wraps json.Unmarshal failures with \"parsing central config %s: %w\", including the file path. It means the central config exists and was read but is not valid JSON matching the Config schema.","triggerScenarios":"LoadCentralConfig(path) when the file contains truncated JSON, comments, trailing commas, or fields of the wrong type (e.g. a string where a number is expected).","commonSituations":"Hand-edited central config with a syntax error; merge conflict markers left in the file; partial write from a crashed editor or interrupted sync.","solutions":["Validate the JSON: `python3 -m json.tool <path>` or `jq . <path>` and fix the syntax error","Remove merge-conflict markers (<<<<<<< ======= >>>>>>>) from the file","Restore the file from git or a backup","Check the wrapped inner error message for the exact line/offset of the JSON fault"],"exampleFix":"// before (central.json)\n{\"defaults\": {\"dolt.mode\": server,}}\n// after\n{\"defaults\": {\"dolt.mode\": \"server\"}}","handlingStrategy":"validation","validationCode":"data, _ := os.ReadFile(path)\nif json.Unmarshal(data, &struct{}{}) != nil {\n    // fix JSON before bd reads it: run python3 -m json.tool or jq . on the file\n}","typeGuard":null,"tryCatchPattern":"cfg, err := bd.LoadCentralConfig(path)\nif err != nil {\n    var perr *json.SyntaxError\n    if errors.As(err, &perr) { /* perr.Offset locates the fault */ }\n    return err\n}","preventionTips":["Run a JSON linter on central config after every manual edit","Search for merge-conflict markers before committing","Edit JSON via schema-aware editors, not plain echo"],"tags":["config","json","parsing"],"backgroundTag":"invalid-config-value","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}