larksuite/cli · error
expected <%s>, got <%s>
Error message
expected <%s>, got <%s>
What it means
parseLocalDocResourceTag: the decoded first XML start element's name is not the tag the caller expected (img/a/etc.) - the block was routed to the wrong parser or the markup deviates; caller wraps it into a typed validation error.
Source
Thrown at shortcuts/doc/local_doc_resources.go:2341
return out.String()
}
func parseLocalDocResourceTag(raw, expected string) (localDocResourceTag, error) {
if expected == "img" {
raw = escapeBareXMLAmpersandsInTagAttr(raw, "href")
}
decoder := xml.NewDecoder(strings.NewReader(raw))
for {
token, err := decoder.Token()
if err != nil {
return localDocResourceTag{}, err
}
start, ok := token.(xml.StartElement)
if !ok {
continue
}
if start.Name.Local != expected {
return localDocResourceTag{}, fmt.Errorf("expected <%s>, got <%s>", expected, start.Name.Local) //nolint:forbidigo // caller wraps with typed validation error.
}
attrs := make([]html5BlockAttr, 0, len(start.Attr))
seenAttrs := make(map[string]struct{}, len(start.Attr))
for _, attr := range start.Attr {
attrName := strings.ToLower(strings.TrimSpace(attr.Name.Local))
if _, exists := seenAttrs[attrName]; exists {
return localDocResourceTag{}, fmt.Errorf("duplicate attribute %q", attrName) //nolint:forbidigo // caller wraps with typed validation error.
}
seenAttrs[attrName] = struct{}{}
attrs = append(attrs, html5BlockAttr{Name: attr.Name.Local, Value: attr.Value})
}
return localDocResourceTag{Name: expected, Attrs: attrs, SelfClosing: strings.HasSuffix(strings.TrimSpace(raw), "/>")}, nil
}
}
func escapeBareXMLAmpersandsInTagAttr(raw, targetAttr string) string {
for i := 1; i < len(raw); {
for i < len(raw) && isXMLSpace(raw[i]) {View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Ensure the local-doc block is the expected tag type, or extend block routing
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at shortcuts/doc/local_doc_resources.go:2341 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/26cc7b4d78aee5d7.
Report an issue: GitHub.