swc-project/swc · error · Error

Non-space character in "colgroup" element

Error message

Non-space character in "colgroup" element

What it means

HTML parse error in the 'in column group' insertion mode: a non-whitespace character token was found inside <colgroup>, where only col/template/whitespace-ish tokens are allowed. The error is recorded; if the current node is colgroup it is popped and the token is reprocessed in 'in table', otherwise it is ignored.

Source

Thrown at crates/swc_html_parser/src/parser/mod.rs:5189

                    // An end-of-file token
                    // Process the token using the rules for the "in body" insertion mode.
                    Token::Eof => {
                        self.process_token_using_rules(token_and_info, InsertionMode::InBody)?;
                    }
                    // Anything else
                    //
                    // 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)?;
                        }
                    },
                }

View on GitHub (pinned to 5176682b65)

Solutions

  1. Remove text content from inside <colgroup>; it may only contain <col> and <template>
  2. Move the content into a <tbody>/<tr>/<td> structure instead
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/swc_html_parser/src/parser/mod.rs:5189 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/baf8b8cf82ad38f1. Report an issue: GitHub.