{"record":{"id":"a2fff58edc9a7679","repo":"larksuite/cli","slug":"invalid-json-in-s-w","errorCode":null,"errorMessage":"invalid JSON in %s: %w","messagePattern":"invalid JSON in (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/binding/lark_channel.go","lineNumber":56,"sourceCode":"// chmod-0400 file outside the bridge dir, or an exec script that decrypts a\n// local AES-encrypted secret store. Aligns lark-channel with the same secret\n// protocol openclaw already uses.\ntype LarkChannelApp struct {\n\tID     string      `json:\"id\"`\n\tSecret SecretInput `json:\"secret\"`\n\tTenant string      `json:\"tenant\"` // \"feishu\" | \"lark\"\n}\n\n// ReadLarkChannelConfig reads and parses ~/.lark-channel/config.json.\nfunc ReadLarkChannelConfig(path string) (*LarkChannelRoot, error) {\n\tdata, err := vfs.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, err // caller formats user-facing message with path context\n\t}\n\n\tvar root LarkChannelRoot\n\tif err := json.Unmarshal(data, &root); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid JSON in %s: %w\", path, err)\n\t}\n\n\treturn &root, nil\n}\n","sourceCodeStart":38,"sourceCodeEnd":61,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/binding/lark_channel.go#L38-L61","documentation":"ReadLarkChannelConfig reads ~/.lark-channel/config.json and unmarshals it into LarkChannelRoot. If the bytes are not syntactically valid JSON (or types don't match the schema, e.g. a string where an object is expected), the error is wrapped with the file path and the underlying json.Unmarshal error so the exact syntax problem is visible.","triggerScenarios":"json.Unmarshal returns an error for the file contents: truncated file, trailing commas, comments (not allowed in JSON), BOM prefix, single quotes, or a type mismatch like \"accounts\": \"none\".","commonSituations":"Hand-editing config.json and leaving a stray comma; file corrupted by a crashed writer; secrets templating tool replacing values with invalid placeholders; pasting JSON5/JSONC with comments.","solutions":["Validate the file with a JSON linter: `jq . <path>` or `python3 -m json.tool <path>`","Fix the reported syntax error at the line/column given in the wrapped error","Restore config.json from a backup or regenerate it via the bridge/CLI setup","Remove comments/BOM and ensure string values are properly quoted"],"exampleFix":"// before (config.json)\n{\"accounts\": {\"app\": {\"id\": \"x\", \"secret\": \"y\",}}}\n// after\n{\"accounts\": {\"app\": {\"id\": \"x\", \"secret\": \"y\"}}}","handlingStrategy":"try-catch","validationCode":"data, err := os.ReadFile(cfgPath)\nif err != nil { return err }\nif !json.Valid(data) {\n    return fmt.Errorf(\"%s is not valid JSON\", cfgPath)\n}","typeGuard":null,"tryCatchPattern":"cfg, err := binding.ReadLarkChannelConfig(path)\nif err != nil {\n    var syntaxErr *json.SyntaxError\n    if errors.As(err, &syntaxErr) {\n        log.Fatalf(\"%s line %d: %v\", path, syntaxErr.Offset, syntaxErr)\n    }\n    return err\n}","preventionTips":["Run `jq . config.json` after every manual edit","Generate config via the tooling instead of hand-editing","Keep backups; avoid editors/templates that inject comments or BOMs"],"tags":["json","config","parsing"],"backgroundTag":"invalid-json-config","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}