plandex-ai/plandex · error

error parsing embedded schema %s: %v

Error message

error parsing embedded schema %s: %v

What it means

LoadJSON successfully read the embedded schema file but json.Decoder.Decode failed to parse its contents as JSON. This indicates the embedded schema file itself is malformed, or the wrong (non-JSON) file was embedded at that path.

Source

Thrown at app/cli/schema/schemas.go:119

	if strings.HasPrefix(source, webPrefix) {
		source = path.Join("json-schemas", strings.TrimPrefix(source, webPrefix))
	}

	if strings.HasSuffix(source, ".schema.json") {
		schemaPath := source
		// for schemas with relative path references, add the json-schemas prefix
		if !strings.HasPrefix(schemaPath, "json-schemas/") {
			schemaPath = path.Join("json-schemas", schemaPath)
		}
		data, err := l.fs.ReadFile(schemaPath)
		if err != nil {
			return nil, fmt.Errorf("error reading embedded schema %s: %v", schemaPath, err)
		}
		var v interface{}
		dec := json.NewDecoder(bytes.NewReader(data))
		dec.UseNumber() // use numbers instead of floats
		if err := dec.Decode(&v); err != nil {
			return nil, fmt.Errorf("error parsing embedded schema %s: %v", source, err)
		}
		return v, nil
	}

	var v interface{}
	dec := json.NewDecoder(bytes.NewReader([]byte(source)))
	dec.UseNumber() // use numbers instead of floats
	if err := dec.Decode(&v); err != nil {
		return nil, fmt.Errorf("error parsing schema JSON: %v", err)
	}
	return v, nil
}

func (l *embeddedSchemaLoader) JsonReference() (gojsonreference.JsonReference, error) {
	return gojsonreference.NewJsonReference(scheme + l.source)
}

type embeddedLoaderFactory struct{}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Validate the schema file with jq or a JSON linter and fix the syntax
  2. Remove merge-conflict markers from the schema file
  3. Rebuild to ensure the correct schema version is embedded
  4. Restore the schema file from a known-good commit

Example fix

// before (schema file)
{"type": "object", <<<<<<< HEAD
// after
{"type": "object", "properties": {}}
Defensive patterns

Strategy: validation

Validate before calling

func schemaFileValid(p string) error {
    data, err := os.ReadFile(p)
    if err != nil { return err }
    var v interface{}
    return json.Unmarshal(data, &v)
}
// run against json-schemas/*.json in CI before embedding

Try / catch

err := validateJSON[T](data, schemaPath)
if err != nil && strings.Contains(err.Error(), "error parsing embedded schema") {
    // embedded asset corrupt: surface schema path and suggest rebuild
    return fmt.Errorf("embedded schema corrupt: %w", err)
}

Prevention

When it happens

Trigger: The file at json-schemas/<schemaPath> contains invalid JSON: truncated file, merge-conflict markers committed into the schema, YAML saved with a .json extension, or non-UTF-8 bytes.

Common situations: A schema edit was committed with syntax errors; a bad merge left <<<<<<< markers in the schema file; build-time embedding picked up a draft/broken version.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/c7dbbbfcabd4a91e. Report an issue: GitHub.