swc-project/swc · error · Error
Garbage in "colgroup" element
Error message
Garbage in "colgroup" element
What it means
HTML parse error in the 'in column group' anything-else branch: a token (other than the allowed col/template/whitespace forms) was seen while in <colgroup>, and the current node was not the colgroup element ('garbage' in colgroup). The token is ignored after recording the error, or colgroup is popped and the token reprocessed.
Source
Thrown at crates/swc_html_parser/src/parser/mod.rs:5195
//
// If the current node is not a colgroup element, then this is a parse error;
// ignore the token.
//
// Otherwise, pop the current node from the stack of open elements.
//
// Switch the insertion mode to "in table".
//
// Reprocess the token.
_ => match self.open_elements_stack.items.last() {
Some(node) if !is_html_element!(node, "colgroup") => match token {
Token::Character { .. } => {
self.errors.push(Error::new(
token_and_info.span,
ErrorKind::NonSpaceCharacterInColumnGroup,
));
}
_ => {
self.errors.push(Error::new(
token_and_info.span,
ErrorKind::GarbageInColumnGroup,
));
}
},
_ => {
self.open_elements_stack.pop();
self.insertion_mode = InsertionMode::InTable;
self.process_token(token_and_info, None)?;
}
},
}
}
// The "in table body" insertion mode
InsertionMode::InTableBody => {
// When the user agent is to apply the rules for the "in table body" insertion
// mode, the user agent must handle the token as follows:
match token {View on GitHub (pinned to 5176682b65)
Solutions
- Close <colgroup> before emitting table body content
- Remove invalid tokens from inside <colgroup>
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc_html_parser/src/parser/mod.rs:5195 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/ffc4f1bb659cd672.
Report an issue: GitHub.