larksuite/cli · error
value is not JSON-encodable: %w
Error message
value is not JSON-encodable: %w
What it means
compileData rejects a typed data definition that sets both an explicit Output.Data.Shape and Output.Data.Overrides, since a fully explicit shape leaves nothing to override and combining them would be ambiguous. Exactly one authoring style must be chosen.
Source
Thrown at shortcuts/common/typed_compile_contract.go:209
object, ok := shapeAsObject(variant)
if !ok {
return typedObjectShape{}, false
}
if !found {
combined = object
found = true
} else if object.AdditionalProperties {
combined.AdditionalProperties = true
}
}
return combined, found
}
return typedObjectShape{}, false
}
func valueCompatibleWithShape(value any, shape typedValueShape) error {
encoded, err := json.Marshal(value)
if err != nil {
return fmt.Errorf("value is not JSON-encodable: %w", err)
}
normalized, err := decodeJSONValidationValue(encoded)
if err != nil {
return fmt.Errorf("value is not valid JSON: %w", err)
}
return validateJSONValueAgainstShape(normalized, shape, "value")
}
View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Remove the Overrides entries and keep only the explicit Shape.
- Remove the explicit Shape and keep Overrides (struct-derived shape + mutations).
- If overrides are meant to refine a struct-derived shape, drop Shape and let compilation derive it from the Data struct type.
Example fix
// before
Definition{Shape: myShape, Overrides: []Override{{Path:"/a", Value:1}}}
// after
Definition{Shape: myShape} Defensive patterns
Strategy: validation
Validate before calling
func jsonEncodable(v any) error {
var seen map[uintptr]struct{}
_, err := json.Marshal(v)
return err
} Prevention
- Restrict override Value types to JSON-encodable kinds in your wrappers
- Avoid storing chan/func/cyclic references in payload structs
- Unit-test custom MarshalJSON implementations
When it happens
Trigger: Passing typedDataDefinition with both Shape != nil and len(Overrides) > 0 to compileData (directly or via compileDefinitionParts).
Common situations: Migrating from override-based definitions to explicit shapes and leaving stale overrides in place; copy-pasting a definition and adding a Shape without removing Overrides.
Related errors
- Output.Data.Overrides require struct Data
- Data must be a non-pointer struct or any unless Output.Data.
- Pass exactly one of --url or --spreadsheet-token
- Pass only one of --sheet-id or --sheet-name
- multiple plugins called Restrict; only one plugin may own th
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/1e161d5c60c019bc.
Report an issue: GitHub.