larksuite/cli · error
L2: field %q has format: binary but type = %q (want string)
Error message
L2: field %q has format: binary but type = %q (want string)
What it means
walkForL2's recursive per-field check: a property declares format: binary (file upload) but its JSON type is not string - binary payloads are transported as strings, so the combination is contradictory.
Source
Thrown at internal/schema/lint.go:123
errs = append(errs, fmt.Errorf("L3: _meta.access_tokens contains invalid value %q (allowed: user, bot)", t))
}
}
return errs
}
// walkForL2 recursively applies per-field L2 checks (format:binary on
// non-string; minimum>=maximum) plus the sub-object required-exists invariant.
// Required only matters on object-typed Properties (e.g. the params / data
// wrappers); leaf scalars ignore it.
func walkForL2(props *OrderedProps, errs *[]error) {
if props == nil {
return
}
for _, k := range props.Order {
p := props.Map[k]
if p.Format == "binary" && p.Type != "string" {
*errs = append(*errs, fmt.Errorf("L2: field %q has format: binary but type = %q (want string)", k, p.Type))
}
if p.Minimum != nil && p.Maximum != nil && *p.Minimum >= *p.Maximum {
*errs = append(*errs, fmt.Errorf("L2: field %q minimum (%v) >= maximum (%v)", k, *p.Minimum, *p.Maximum))
}
if n := len(p.EnumDescriptions); n > 0 && n != len(p.Enum) {
*errs = append(*errs, fmt.Errorf("L2: field %q enumDescriptions length (%d) != enum length (%d)", k, n, len(p.Enum)))
}
if len(p.Required) > 0 && p.Properties != nil {
for _, r := range p.Required {
if _, ok := p.Properties.Map[r]; !ok {
*errs = append(*errs, fmt.Errorf("L2: required key %q in %q not found in its properties", r, k))
}
}
}
if p.Properties != nil {
walkForL2(p.Properties, errs)
}
}View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Set the property's Type to "string" while keeping Format: "binary"
- Remove the format:"binary" if the field is not actually binary
- Fix the code/metadata generator that emitted the wrong type
Example fix
// before
Property{Type: "object", Format: "binary"}
// after
Property{Type: "string", Format: "binary"} Defensive patterns
Strategy: validation
Validate before calling
for _, p := range props {
if p.Format == "binary" && p.Type != "string" {
return fmt.Errorf("binary field %s must have type string", name)
}
} Type guard
func isBinaryString(p *Property) bool { return p.Format == "binary" && p.Type == "string" } Prevention
- Remember binary fields are base64 strings in JSON Schema: type string + format binary
- Never set format:"binary" on non-string types
- Check schema output with the `schema` command after metadata edits
When it happens
Trigger: walkForL2 visits a properties map where a property p has p.Format == "binary" and p.Type is something else (e.g. "object", "integer", or a typo).
Common situations: Hand-authoring a file-upload parameter and setting type to "file" or "object" instead of "string"; generator bug emitting wrong type for binary fields.
Related errors
- L2: field %q minimum (%v) >= maximum (%v)
- L2: field %q enumDescriptions length (%d) != enum length (%d
- L2: required key %q in %q not found in its properties
- L1: property %q has invalid type %q
- L1: array property %q missing items
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/dc5215b89aea8915.
Report an issue: GitHub.