{"record":{"id":"3e2c83f2016c34c8","repo":"biomejs/biome","slug":"generated-promise-member-has-unexpected-shape","errorCode":null,"errorMessage":"generated Promise.{} member has unexpected shape","messagePattern":"generated Promise\\.(.+?) member has unexpected shape","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/codegen/src/generate_global_types/compare.rs","lineNumber":312,"sourceCode":"\n/// Checks one Promise member and the synthetic callable referenced by that member.\nfn assert_promise_method(\n    class: &LoweredClass,\n    lowered: &LoweredGlobalTypes,\n    shape: PromiseMethodShape,\n) -> Result<()> {\n    let Some(member) = class.member(shape.member_name) else {\n        bail!(\"generated Promise global is missing {}\", shape.member_name);\n    };\n    let expected_kind = if shape.is_static {\n        LoweredMemberKind::NamedStatic\n    } else {\n        LoweredMemberKind::Named { optional: false }\n    };\n    if member.kind() != &expected_kind\n        || member.type_reference() != &LoweredTypeReference::Predefined(shape.member_type_id)\n    {\n        bail!(\n            \"generated Promise.{} member has unexpected shape\",\n            shape.member_name\n        );\n    }\n\n    let helper = generated_function(lowered, shape.helper_name, shape.helper_id_constant)?;\n    if helper.is_async()\n        || !helper.type_parameters().is_empty()\n        || helper.name() != Some(shape.helper_name)\n        || !helper.parameters().is_empty()\n        || helper.return_type() != &LoweredTypeReference::Predefined(\"GLOBAL_INSTANCEOF_PROMISE_ID\")\n    {\n        bail!(\n            \"generated {} helper has unexpected shape\",\n            shape.helper_name\n        );\n    }\n    Ok(())","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/biomejs/biome/blob/3835945f0638c88162351318b7bc8b64c5f2fba7/xtask/codegen/src/generate_global_types/compare.rs#L294-L330","documentation":"This invariant failure is raised by Biome's xtask code generator while validating that a generated Promise member (e.g. Promise.prototype.then) matches the shape declared in the codegen manifest: its lowered kind and type reference must equal the expected values. A mismatch means the Web IDL/TS source of truth changed in a way the generator's assumptions no longer cover, so the build stops rather than emitting inconsistent global type definitions.","triggerScenarios":"Running `cargo xtask codegen` (global types generation) after the Promise member's declared type or optionality changed upstream, so member.kind() or member.type_reference() no longer matches the expected LoweredMemberKind / Predefined type id in the manifest shape.","commonSituations":"Updating the bundled lib.global typings or the generator manifest; a contributor edits Promise method signatures in the source declarations without updating the expected shape tables; a codegen refactor changes lowering behavior so Predefined type ids no longer line up.","solutions":["Compare the generated Promise member's kind and type reference against shape.member_name in the manifest and update the expected shape (member type id / optional flag) to match the new declaration.","If the source declaration is wrong, fix the Promise member declaration in the global typings input instead.","After updating expectations, regenerate with `cargo xtask codegen` and commit regenerated files."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// In xtask: pre-validate before compare\nfn validate_promise_member(member: &LoweredMember, shape: &PromiseShape) -> Result<()> {\n  let expected = LoweredMemberKind::Named { optional: false };\n  ensure!(member.kind() == &expected, \"member kind drifted for {}\", shape.member_name);\n  ensure!(member.type_reference() == &LoweredTypeReference::Predefined(shape.member_type_id), \"member type drifted for {}\", shape.member_name);\n  Ok(())\n}","typeGuard":null,"tryCatchPattern":"match assert_promise_shape(&lowered, &shape) {\n  Err(e) if e.to_string().contains(\"unexpected shape\") => {\n    eprintln!(\"Regeneration required: {e}; run `cargo xtask codegen` after updating expectations\");\n    std::process::exit(1);\n  }\n  Err(e) => return Err(e),\n  Ok(()) => {}\n}","preventionTips":["Keep Promise member shape expectations in one table next to the generator and update both together.","Run `cargo xtask codegen` locally before committing changes to global typings.","Review regenerated global-types diffs in CI to catch drift early.","Avoid hand-edits to generated global type output."],"tags":["codegen","rust","build","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"3835945f0638c88162351318b7bc8b64c5f2fba7","analyzedAt":"2026-09-13T15:11:16.919Z","contentChangedAt":"2026-09-13T15:11:16.919Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}