{"record":{"id":"05d8dab664dfaa89","repo":"plandex-ai/plandex","slug":"error-parsing-schema-json-v","errorCode":null,"errorMessage":"error parsing schema JSON: %v","messagePattern":"error parsing schema JSON: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/schema/schemas.go","lineNumber":128,"sourceCode":"\t\t}\n\t\tdata, err := l.fs.ReadFile(schemaPath)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error reading embedded schema %s: %v\", schemaPath, err)\n\t\t}\n\t\tvar v interface{}\n\t\tdec := json.NewDecoder(bytes.NewReader(data))\n\t\tdec.UseNumber() // use numbers instead of floats\n\t\tif err := dec.Decode(&v); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error parsing embedded schema %s: %v\", source, err)\n\t\t}\n\t\treturn v, nil\n\t}\n\n\tvar v interface{}\n\tdec := json.NewDecoder(bytes.NewReader([]byte(source)))\n\tdec.UseNumber() // use numbers instead of floats\n\tif err := dec.Decode(&v); err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing schema JSON: %v\", err)\n\t}\n\treturn v, nil\n}\n\nfunc (l *embeddedSchemaLoader) JsonReference() (gojsonreference.JsonReference, error) {\n\treturn gojsonreference.NewJsonReference(scheme + l.source)\n}\n\ntype embeddedLoaderFactory struct{}\n\nfunc (embeddedLoaderFactory) New(source string) gojsonschema.JSONLoader {\n\tsource = strings.TrimPrefix(source, scheme)\n\treturn newEmbeddedSchemaLoader(SchemaPath(source))\n}\n\nfunc (l *embeddedSchemaLoader) LoaderFactory() gojsonschema.JSONLoaderFactory {\n\treturn embeddedLoaderFactory{}\n}","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/schema/schemas.go#L110-L146","documentation":"LoadJSON treats its source string as a literal JSON schema document (not a path) and decodes it with json.Decoder. This error means the provided source string is not valid JSON — e.g. an accidental non-JSON string was passed instead of a schema path or schema JSON.","triggerScenarios":"Calling LoadJSON with a source string containing invalid JSON: passing a schema name/path instead of JSON content while the embedded-path branch was skipped, or a malformed inline schema.","commonSituations":"Confusing the loader API by passing a filename where raw JSON is expected; inline schema copy-pasted with comments or trailing commas.","solutions":["Confirm whether LoadJSON expects a path or raw JSON and pass the right one","Validate the inline schema string with jq and fix syntax errors","If you meant a file, use the embedded loader path so it is read as a file","Remove JSON-incompatible syntax (comments, trailing commas)"],"exampleFix":"// before\nloader.LoadJSON(\"model-pack-schema\") // raw string, not JSON\n// after\nloader.LoadJSON(`{\"type\":\"object\",\"properties\":{}}`)","handlingStrategy":"validation","validationCode":"func isJSONString(s string) bool {\n    var v interface{}\n    return json.Unmarshal([]byte(s), &v) == nil\n}\n// check before calling LoadJSON with inline schema source","typeGuard":null,"tryCatchPattern":"v, err := loader.LoadJSON(source)\nif err != nil && strings.Contains(err.Error(), \"error parsing schema JSON\") {\n    // source was meant to be a file path or is malformed JSON\n    return fmt.Errorf(\"inline schema is not valid JSON: %w\", err)\n}","preventionTips":["Pass schema paths to the path-based loader, raw JSON only to the inline variant","Validate inline schema strings with jq before use","Strip comments and trailing commas (JSON does not allow them)"],"tags":["json","schema","parsing"],"backgroundTag":"invalid-json","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}