{"record":{"id":"2a117ed44888e846","repo":"microsoft/TypeScript","slug":"variations-in-test-option-varyby-resulted-in","errorCode":null,"errorMessage":"Variations in test option '@${varyBy}' resulted in an empty set.","messagePattern":"Variations in test option '@(.+?)' resulted in an empty set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/harness/harnessIO.ts","lineNumber":1124,"sourceCode":"        // add all entries\r\n        for (const [key, value] of ts.arrayFrom(values.entries())) {\r\n            if (ts.findIndex(variations, v => v.key === key || v.value === value) === -1) {\r\n                variations.push({ key, value });\r\n            }\r\n        }\r\n    }\r\n\r\n    // remove all excluded entries\r\n    for (const exclude of excludes) {\r\n        const value = values?.get(exclude);\r\n        let index: number;\r\n        while ((index = ts.findIndex(variations, v => v.key === exclude || value !== undefined && v.value === value)) >= 0) {\r\n            ts.orderedRemoveItemAt(variations, index);\r\n        }\r\n    }\r\n\r\n    if (variations.length === 0) {\r\n        throw new Error(`Variations in test option '@${varyBy}' resulted in an empty set.`);\r\n    }\r\n\r\n    return ts.map(variations, v => v.key);\r\n}\r\n\r\nfunction computeFileBasedTestConfigurationVariations(configurations: FileBasedTestConfiguration[], variationState: FileBasedTestConfiguration, varyByEntries: [string, string[]][], offset: number) {\r\n    if (offset >= varyByEntries.length) {\r\n        // make a copy of the current variation state\r\n        configurations.push({ ...variationState });\r\n        return;\r\n    }\r\n\r\n    const [varyBy, entries] = varyByEntries[offset];\r\n    for (const entry of entries) {\r\n        // set or overwrite the variation, then compute the next variation\r\n        variationState[varyBy] = entry;\r\n        computeFileBasedTestConfigurationVariations(configurations, variationState, varyByEntries, offset + 1);\r\n    }\r","sourceCodeStart":1106,"sourceCodeEnd":1142,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/harness/harnessIO.ts#L1106-L1142","documentation":"Thrown while resolving `@<varyBy>` test-option variations in harnessIO.ts:1124. After includes, the `*` star expansion, and excludes are applied to the variation set for a single varyBy key, if nothing remains the harness aborts — it refuses to run a variation matrix that collapses to zero cases.","triggerScenarios":"A test metadata line like `// @target: es5 exclude=es5`, or `// @target: exclude=*`, or includes whose keys/values do not match any entry in the option's declared domain (ts.optionDeclarations). The exclude loop at harnessIO.ts:1115-1121 removes every entry that was previously added.","commonSituations":"Typing a value in `exclude=` that matches every included entry; listing an exclude key that is also the only include; using a value that does not exist in the option's map so `*` expansion yields nothing; copy-pasting an exclude clause from a similar option without adjusting it.","solutions":["Open the test file and inspect the `// @<varyBy>: <includes> exclude=<excludes>` line; ensure the exclude list does not cover every included value.","If you intended to disable variation for that key, remove the `// @<varyBy>` line entirely rather than excluding everything.","Cross-check the option name and values against ts.optionDeclarations (getVaryByStarSettingValues at harnessIO.ts:1147) — values must exist in the option's domain or `*` resolves to nothing.","Add at least one include value that is not in the exclude set."],"exampleFix":"// before — exclude removes the only include\n// @target: es5 exclude=es5\n\n// after — keep at least one non-excluded value\n// @target: es5,esnext exclude=es5","handlingStrategy":"validation","validationCode":"// Validate include/exclude combinations before relying on getFileBasedTestConfigurations.\nfunction variationSetIsNonEmpty(includes: string[], excludes: string[], starValues?: ReadonlyMap<string, unknown>): boolean {\n  const all = new Set<string>(includes);\n  if (starValues) for (const k of starValues.keys()) all.add(k);\n  for (const ex of excludes) all.delete(ex);\n  return all.size > 0;\n}","typeGuard":"function hasSurvivingVariation(includes: readonly string[], excludes: readonly string[]): boolean {\n  const ex = new Set(excludes);\n  return includes.some(i => !ex.has(i));\n}","tryCatchPattern":null,"preventionTips":["Never list the same value in both include and exclude for a single varyBy key.","Prefer removing the @<varyBy> line entirely over `exclude=*` when you want no variation.","Cross-check values against ts.optionDeclarations so unknown values do not silently yield an empty set."],"tags":["test-harness","test-options","varyby","configuration"],"backgroundTag":null,"analyzedSha":"b465fdbfe175304d9b977da137b2c178ae1091d3","analyzedAt":"2026-08-12T05:38:42.698Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}