biomejs/biome · error

failed to get text of map value

Error message

failed to get text of map value

What it means

Error "failed to get text of map value" thrown in biomejs/biome.

Source

Thrown at crates/biome_grit_patterns/src/grit_resolved_pattern.rs:780

                .iter()
                .try_fold(String::new(), |mut text, snippet| {
                    text.push_str(&snippet.text(state, language)?);
                    Ok::<String, GritPatternError>(text)
                })?
                .into()),
            Self::List(list) => Ok(list
                .iter()
                .map(|pattern| pattern.text(state, language))
                .collect::<GritResult<Vec<_>>>()?
                .join(",")
                .into()),
            Self::Map(map) => Ok(format!(
                "{{{}}}",
                map.iter()
                    .map(|(key, value)| {
                        let value = value
                            .text(state, language)
                            .expect("failed to get text of map value");
                        format!("\"{key}\": {value}")
                    })
                    .reduce(|mut acc, entry| {
                        acc.push_str(", ");
                        acc.push_str(&entry);
                        acc
                    })
                    .unwrap_or_default()
            )
            .into()),
            Self::File(file) => Ok(format!(
                "{}:\n{}",
                file.name(state).text(state, language)?,
                file.body(state).text(state, language)?
            )
            .into()),
            Self::Files(files) => files.text(state, language),
            Self::Constant(constant) => Ok(constant.to_string().into()),

View on GitHub (pinned to 405dedb0ff)

Solutions

  1. Ensure the Grit pattern's map value node actually contains text before resolving it.
  2. This is an internal invariant; report it with the Grit query that triggered it.

Example fix

// Report at https://github.com/biomejs/biome/issues with the failing Grit pattern

When it happens

Trigger: Thrown at crates/biome_grit_patterns/src/grit_resolved_pattern.rs:780 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of biomejs/biome@405dedb0ff (2026-08-20). Data as JSON: /api/errors/f9c01c6e612ad452. Report an issue: GitHub.