{"record":{"id":"82d5e6199a3f3c8d","repo":"larksuite/cli","slug":"missing-start-element","errorCode":null,"errorMessage":"missing start element","messagePattern":"missing start element","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/doc/html5_block_resources.go","lineNumber":895,"sourceCode":"\t\t\tif errors.Is(err, io.EOF) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn html5BlockStartTag{}, err\n\t\t}\n\t\tstart, ok := tok.(xml.StartElement)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\t\tif start.Name.Local != html5BlockTag {\n\t\t\treturn html5BlockStartTag{}, fmt.Errorf(\"expected <%s>, got <%s>\", html5BlockTag, start.Name.Local) //nolint:forbidigo // intermediate parse helper; callers wrap with typed validation errors.\n\t\t}\n\t\tattrs := make([]html5BlockAttr, 0, len(start.Attr))\n\t\tfor _, attr := range start.Attr {\n\t\t\tattrs = append(attrs, html5BlockAttr{Name: attr.Name.Local, Value: attr.Value})\n\t\t}\n\t\treturn html5BlockStartTag{Attrs: attrs, SelfClosing: selfClosing}, nil\n\t}\n\treturn html5BlockStartTag{}, fmt.Errorf(\"missing start element\") //nolint:forbidigo // intermediate parse helper; callers wrap with typed validation errors.\n}\n\nfunc parseWhiteboardStartTag(raw string) (whiteboardStartTag, error) {\n\ttrimmed := strings.TrimSpace(raw)\n\tselfClosing := strings.HasSuffix(trimmed, \"/>\")\n\tdecoder := xml.NewDecoder(strings.NewReader(raw))\n\tfor {\n\t\ttok, err := decoder.Token()\n\t\tif err != nil {\n\t\t\tif errors.Is(err, io.EOF) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn whiteboardStartTag{}, err\n\t\t}\n\t\tstart, ok := tok.(xml.StartElement)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}","sourceCodeStart":877,"sourceCodeEnd":913,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/doc/html5_block_resources.go#L877-L913","documentation":"parseHTML5BlockStartTag scans tokens until the first xml.StartElement; if the fragment is exhausted (EOF) without ever seeing a start element — the input is empty, contains only text/comments/processing instructions, or is self-closing markup the tokenizer did not surface as an element — it returns 'missing start element'. Callers wrap it in typed validation errors.","triggerScenarios":"Rewriting a doc resource block where the extracted start-tag fragment is empty, whitespace/comment-only, plain text, or otherwise contains no element token.","commonSituations":"Doc content where the expected block wrapper is absent (already-flattened content), empty resource placeholders, or upstream extraction bugs slicing markup incorrectly.","solutions":["Check the raw fragment in the wrapped error; verify the block wrapper actually exists in the source document.","Re-export or re-convert the document so the expected HTML5 block structure is regenerated.","If processing programmatically, validate the fragment contains a start element (e.g. via xml.Decoder peek) before calling the rewrite API."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify the fragment contains an element before rewriting:\ntrimmed := strings.TrimSpace(fragment)\nif trimmed == \"\" || !strings.Contains(trimmed, \"<\") {\n    return errs.NewValidationError(errs.SubtypeInvalidArgument, \"empty html5 block fragment\")\n}","typeGuard":"func fragmentHasStartElement(fragment string) bool {\n    dec := xml.NewDecoder(strings.NewReader(fragment))\n    for {\n        tok, err := dec.Token()\n        if err != nil { return false }\n        if _, ok := tok.(xml.StartElement); ok { return true }\n    }\n}","tryCatchPattern":"out, err := parseHTML5BlockStartTag(raw)\nif err != nil {\n    return errs.NewValidationError(errs.SubtypeInvalidArgument, \"html5 block missing wrapper: %s\", err).WithCause(err)\n}","preventionTips":["Check that the source document actually contains the block wrapper before extracting fragments.","Re-export or re-convert documents whose content appears already flattened.","Log the raw fragment when extraction fails so empty/whitespace-only slices are caught early."],"tags":["html","xml-parsing","doc-rewrite","empty-input"],"backgroundTag":"unexpected-html-element","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}