evanw/esbuild · error · Error

Missing YAML metadata

Error message

Missing YAML metadata

What it means

Thrown at scripts/test262.js:437. Each test262 conformance file must contain a YAML metadata block delimited by `/*---` and `---*/`. The harness locates these markers with indexOf; if either marker is absent (indexOf returns -1) the file is rejected because the harness cannot read the flags, includes, and features metadata it needs to run the test.

Source

Thrown at scripts/test262.js:437

  console.log(`\n${dimColor}Installing esbuild...${resetColor}`)
  const esbuild = installForTests()

  console.log(`\n${dimColor}Running tests...${resetColor}\n`)
  const errorCounts = {}
  let skippedCount = 0

  await forEachInParallel(files, 32, async (file) => {
    // Don't parse files that esbuild deliberately handles differently
    if (skipTheseTests.has(path.relative(testDir, file))) {
      skippedCount++
      return
    }

    try {
      const content = fs.readFileSync(file, 'utf8')
      const start = content.indexOf('/*---')
      const end = content.indexOf('---*/')
      if (start < 0 || end < 0) throw new Error(`Missing YAML metadata`)
      const yaml = jsYaml.safeLoad(content.slice(start + 5, end))

      // Don't parse files that test things we don't care about
      if (yaml.features && yaml.features.some(feature => skipTheseFeatures.has(feature))) {
        skippedCount++
        return
      }

      await checkTransformAPI({ esbuild, file, content, yaml })
      await checkBuildAPI({ esbuild, file, content, yaml })
    }

    catch (error) {
      errorCounts[error.kind] = (errorCounts[error.kind] || 0) + 1
      printError(file, error)
    }
  })

View on GitHub (pinned to f6058f8364)

Solutions

  1. Confirm the failing file is actually a test262 test (not a harness/helper file) and should have metadata.
  2. Ensure the file contains a `/*---` ... `---*/` block with valid YAML (description, flags, includes as needed).
  3. If the file is legitimately header-less, exclude it from the file glob in scripts/test262.js.

Example fix

// before (file body only)
var x = 1;
assert.sameValue(x, 1);

// after (YAML metadata block added)
/*---
description: basic assign test
flags: []
---*/
var x = 1;
assert.sameValue(x, 1);
Defensive patterns

Strategy: validation

Validate before calling

function hasTest262Metadata(content) {
  return content.indexOf('/*---') >= 0 && content.indexOf('---*/') >= 0;
}

Try / catch

try { const yaml = loadTest262Yaml(content); }
catch (e) {
  if (/Missing YAML metadata/.test(e.message)) console.error('File lacks a /*--- ... ---*/ metadata block');
  throw e;
}

Prevention

When it happens

Trigger: Running scripts/test262.js against a test262 tree where one or more .js files lack the standard `/*--- ... ---*/` front-matter block — e.g. a harness helper file, a malformed fixture, or a file from a test262 checkout whose format changed.

Common situations: The test262 submodule/checkout is updated to a version that renamed markers, a non-test file is accidentally included in the test glob, or a locally-added fixture omits the YAML header.

Related errors


AI-assisted analysis of evanw/esbuild@f6058f8364 (2026-08-09). Data as JSON: /api/errors/1ff0255d094bd530. Report an issue: GitHub.