larksuite/cli · error
parse base schema for field overrides: %w
Error message
parse base schema for field overrides: %w
What it means
resolveSchemaJSON in internal/event/catalog/compile.go fails when the base event schema JSON cannot be unmarshaled into a map prior to applying def.Schema.FieldOverrides. This step is only taken when field overrides exist; the wrap makes the JSON syntax/shape error diagnosable in a compile context.
Source
Thrown at internal/event/catalog/compile.go:238
return nil, nil, nil
}
base, err := renderSpec(spec)
if err != nil {
return nil, nil, err
}
if base == nil {
return nil, nil, nil
}
if isNative {
base = schemas.WrapV2Envelope(base)
}
if len(def.Schema.FieldOverrides) > 0 {
var parsed map[string]any
if err := json.Unmarshal(base, &parsed); err != nil {
return nil, nil, fmt.Errorf("parse base schema for field overrides: %w", err)
}
orphans := schemas.ApplyFieldOverrides(parsed, def.Schema.FieldOverrides)
out, err := json.Marshal(parsed)
if err != nil {
return nil, nil, fmt.Errorf("serialize schema with field overrides: %w", err)
}
return out, orphans, nil
}
return base, nil, nil
}
// pickSpec returns the non-nil spec and whether it is native (V2-wrapped).
func pickSpec(s SchemaDef) (*SchemaSpec, bool) {
if s.Native != nil {
return s.Native, true
}
if s.Custom != nil {View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Validate the base schema JSON parses (json.Valid or jq) before compiling; fix the invalid schema source
- Ensure FieldOverrides target a base schema that is a JSON object; correct the definition's Schema field
- Re-fetch/rebuild the canonical metadata instead of using a hand-modified schema
- Check for a version mismatch between the code producing the base schema and the compiler
Example fix
// before
base := []byte(`{"type":"object"`) // malformed
// after
if !json.Valid(base) { return nil, nil, fmt.Errorf("invalid base schema") }
return resolveSchemaJSON(base, def) Defensive patterns
Strategy: validation
Validate before calling
if len(def.Schema.FieldOverrides) > 0 && !json.Valid(base) {
return fmt.Errorf("base schema for %s is not valid JSON", def.Name)
} Type guard
func isSchemaParseError(err error) bool { return err != nil && strings.Contains(err.Error(), "parse base schema") } Try / catch
schemaJSON, orphans, err := resolveSchemaJSON(base, def)
if err != nil {
return fmt.Errorf("compile event %s: %w", def.Name, err)
} Prevention
- Validate schema JSON with json.Valid/jq before feeding custom definitions to Compile
- Ensure base schemas are JSON objects, not arrays or scalars
- Use generated/canonical metadata rather than hand-edited schemas
- Test Compile over all definitions in CI to catch bad schema sources early
When it happens
Trigger: Compile() processes an event definition with non-empty Schema.FieldOverrides and json.Unmarshal(base, &parsed) fails because the base schema (possibly produced by WrapV2Envelope) is not valid JSON or is not a JSON object (e.g. array/string/number at top level).
Common situations: A custom or hand-edited event definition supplies a base schema that is invalid JSON; a generator emitted a non-object schema; binary/version mismatch where WrapV2Envelope output shape changed; metadata fetched from the server truncated or corrupted.
Related errors
- serialize schema with field overrides: %w
- lark-cli returned a non-object JSON payload
- schema spec has neither Type nor Raw
- marshal key %q: %w
- marshal value for %q: %w
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/e938bddf2358160a.
Report an issue: GitHub.