swc-project/swc · error

Expected valid length (minimum 1 or maximum 6 hex digits) in

Error message

Expected valid length (minimum 1 or maximum 6 hex digits) in the start of unicode range

What it means

Fired during <urange> validation: the start part of the range must be 1 to 6 hex digits (or '?' wildcards), but zero digits or more than six were consumed. This makes the code-point start value invalid per the spec algorithm.

Source

Thrown at crates/swc_css_parser/src/parser/values_and_units/mod.rs:2942

                    break;
                }
            }
        }

        let mut has_question_mark = false;

        while let Some(c @ '?') = next {
            has_question_mark = true;

            start.push(c);

            next = chars.next();
        }

        let len = start.len();

        if len == 0 || len > 6 {
            return Err(Error::new(
                span,
                ErrorKind::Expected(
                    "valid length (minimum 1 or maximum 6 hex digits) in the start of unicode \
                     range",
                ),
            ));
        }

        // If any U+003F QUESTION MARK (?) code points were consumed, then:
        if has_question_mark {
            // 1. If there are any code points left in text, this is an invalid <urange>,
            // and this algorithm must exit.
            if next.is_some() {
                return Err(Error::new(
                    span,
                    ErrorKind::Expected("no characters after '?' in unicode range"),
                ));
            }

View on GitHub (pinned to 5176682b65)

Solutions

  1. Use between 1 and 6 hex digits for the range start, e.g. 'U+10FFFF'
  2. Limit wildcards so the start part stays within 6 characters
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/swc_css_parser/src/parser/values_and_units/mod.rs:2942 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/5263bab3daa47d8d. Report an issue: GitHub.