facebook/relay · error

should return one deduplicated type per match field

Error message

should return one deduplicated type per match field

What it means

Invariant in maybe_deduplicate_raw_response_types: deduplicate_raw_response_types must return exactly one output type per input match field so the iterator aligns with the match-field list. Firing means the dedup pass dropped or merged match-field types incorrectly when building raw response types for an operation.

Source

Thrown at compiler/crates/relay-typegen/src/write.rs:412

            .feature_flags
            .disable_deduping_common_structures_in_raw_response_types
            .is_enabled_for(operation_name.0)
    {
        let match_fields = match_fields.0.into_iter().collect_vec();
        let raw_response_types = match_fields
            .iter()
            .map(|(_, type_)| type_)
            .chain(std::iter::once(&raw_response_type))
            .collect_vec();
        let deduplicated = deduplicate_raw_response_types(&raw_response_types, operation_name.0);
        let mut deduplicated_types = deduplicated.types.into_iter();
        let match_fields = MatchFields(
            match_fields
                .into_iter()
                .map(|(name, _)| {
                    let type_ = deduplicated_types
                        .next()
                        .expect("should return one deduplicated type per match field");
                    (name, type_)
                })
                .collect(),
        );
        let raw_response_type = deduplicated_types
            .next()
            .expect("should return the deduplicated raw response type");
        debug_assert!(deduplicated_types.next().is_none());

        (
            DeduplicatedType {
                type_: raw_response_type,
                aliases: deduplicated.aliases,
            },
            match_fields,
        )
    } else {
        (

View on GitHub (pinned to 668b1b85e0)

Solutions

  1. Check deduplicate_raw_response_types preserves a 1:1 mapping between input and output types for match fields
  2. Disable the dedup path via disable_deduping_common_structures_in_raw_response_types flag to confirm it as the cause
  3. Add a unit test asserting one deduplicated type per match field
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at compiler/crates/relay-typegen/src/write.rs:412 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of facebook/relay@668b1b85e0 (2026-09-02). Data as JSON: /api/errors/e8c08da4c4820cc3. Report an issue: GitHub.