{"record":{"id":"8bb81c9010b66d34","repo":"gastownhall/beads","slug":"parsing-s-w","errorCode":null,"errorMessage":"parsing %s: %w","messagePattern":"parsing (.+?): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configfile/proxied_server_client_info.go","lineNumber":37,"sourceCode":"\tExternal    *ExternalDoltConfig `json:\"external,omitempty\"`\n}\n\nfunc ProxiedServerClientInfoPath(beadsDir string) string {\n\treturn filepath.Join(beadsDir, ProxiedServerClientInfoFileName)\n}\n\nfunc LoadProxiedServerClientInfo(beadsDir string) (*ProxiedServerClientInfo, error) {\n\tpath := ProxiedServerClientInfoPath(beadsDir)\n\tdata, err := os.ReadFile(path) // #nosec G304 - controlled path\n\tif os.IsNotExist(err) {\n\t\treturn nil, nil\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reading %s: %w\", ProxiedServerClientInfoFileName, err)\n\t}\n\tvar info ProxiedServerClientInfo\n\tif err := json.Unmarshal(data, &info); err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing %s: %w\", ProxiedServerClientInfoFileName, err)\n\t}\n\treturn &info, nil\n}\n\nfunc SaveProxiedServerClientInfo(beadsDir string, info *ProxiedServerClientInfo) error {\n\tif info == nil {\n\t\tinfo = &ProxiedServerClientInfo{}\n\t}\n\tdata, err := json.MarshalIndent(info, \"\", \"  \")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"marshaling %s: %w\", ProxiedServerClientInfoFileName, err)\n\t}\n\tpath := ProxiedServerClientInfoPath(beadsDir)\n\tif err := os.WriteFile(path, data, 0o600); err != nil {\n\t\treturn fmt.Errorf(\"writing %s: %w\", ProxiedServerClientInfoFileName, err)\n\t}\n\treturn nil\n}","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/configfile/proxied_server_client_info.go#L19-L55","documentation":"LoadProxiedServerClientInfo read the file successfully but json.Unmarshal could not parse its contents as ProxiedServerClientInfo, and wraps the JSON error. This means the file exists and is readable but is corrupt, truncated, empty, or was written in a different format than the current struct expects.","triggerScenarios":"Calling LoadProxiedServerClientInfo when the JSON file contains invalid syntax (truncated write, manual edit), is empty (0 bytes), or its fields/types no longer match the ProxiedServerClientInfo struct after a version change.","commonSituations":"Process killed mid-write leaving a partial file; hand-editing the JSON and breaking syntax; upgrading/downgrading bd so the stored shape changed; file corrupted by disk issues or sync tools (Dropbox etc.).","solutions":["Validate the JSON (jq . <file>) to see the exact syntax error at the wrapped offset; fix or restore it.","Delete the corrupt file and restart/reattach the proxied server so SaveProxiedServerClientInfo regenerates it: rm -f .beads/proxied_server_client_info.json.","If you hand-edited it, restore valid JSON matching ProxiedServerClientInfo fields (strings for IDs/addresses, etc.).","Check for a version mismatch — upgrade or downgrade bd so the reader matches the writer's format."],"exampleFix":"// before\n{\"host\": \"127.0.0.1\", \"port\":    // truncated\n// after\n# rm -f .beads/proxied_server_client_info.json && bd <start-server-cmd>\n{\"host\": \"127.0.0.1\", \"port\": 50051}","handlingStrategy":"try-catch","validationCode":"path := filepath.Join(beadsDir, configfile.ProxiedServerClientInfoFileName)\nif data, err := os.ReadFile(path); err == nil {\n    var probe map[string]any\n    if json.Unmarshal(data, &probe) != nil {\n        os.Remove(path) // let the server regenerate it\n    }\n}","typeGuard":null,"tryCatchPattern":"info, err := configfile.LoadProxiedServerClientInfo(beadsDir)\nif err != nil {\n    var jsonErr *json.SyntaxError\n    if errors.As(err, &jsonErr) {\n        log.Printf(\"corrupt proxied server info at offset %d: %v — regenerating\", jsonErr.Offset, jsonErr)\n        os.Remove(filepath.Join(beadsDir, configfile.ProxiedServerClientInfoFileName))\n    }\n    return err\n}","preventionTips":["Never hand-edit the generated JSON file","Use atomic writes (temp file + rename) when tooling writes this file","After crashes or version upgrades, delete and regenerate rather than repair"],"tags":["json","parsing","corruption","config"],"backgroundTag":"config-file-parse-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}