{"record":{"id":"e04d13b2a9a06f1b","repo":"vitest-dev/vitest","slug":"tag-name-tag-name-is-invalid-tag-names-canno-e04d13","errorCode":null,"errorMessage":"Tag name \"${tag.name}\" is invalid. Tag names cannot contain \"!\", \"*\", \"&\", \"|\", \"(\", or \")\".","messagePattern":"Tag name \"(.+?)\" is invalid\\. Tag names cannot contain \"!\", \"\\*\", \"&\", \"\\|\", \"\\(\", or \"\\)\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/config/resolveConfig.ts","lineNumber":299,"sourceCode":"\n  resolved.project = toArray(resolved.project)\n  resolved.provide ??= {}\n\n  // shallow copy tags array to avoid mutating user config\n  resolved.tags = [...resolved.tags || []]\n  const definedTags = new Set<string>()\n  resolved.tags.forEach((tag) => {\n    if (!tag.name || typeof tag.name !== 'string') {\n      throw new Error(`Each tag defined in \"test.tags\" must have a \"name\" property, received: ${JSON.stringify(tag)}`)\n    }\n    if (definedTags.has(tag.name)) {\n      throw new Error(`Tag name \"${tag.name}\" is already defined in \"test.tags\". Tag names must be unique.`)\n    }\n    if (/\\s/.test(tag.name)) {\n      throw new Error(`Tag name \"${tag.name}\" is invalid. Tag names cannot contain spaces.`)\n    }\n    if (/[!()*|&]/.test(tag.name)) {\n      throw new Error(`Tag name \"${tag.name}\" is invalid. Tag names cannot contain \"!\", \"*\", \"&\", \"|\", \"(\", or \")\".`)\n    }\n    if (/^\\s*(?:and|or|not)\\s*$/i.test(tag.name)) {\n      throw new Error(`Tag name \"${tag.name}\" is invalid. Tag names cannot be a logical operator like \"and\", \"or\", \"not\".`)\n    }\n    if (typeof tag.retry === 'object' && typeof tag.retry.condition === 'function') {\n      throw new TypeError(`Tag \"${tag.name}\": retry.condition function cannot be used inside a config file. Use a RegExp pattern instead, or define the function in your test file.`)\n    }\n    if (tag.priority != null && (typeof tag.priority !== 'number' || tag.priority < 0)) {\n      throw new TypeError(`Tag \"${tag.name}\": priority must be a non-negative number.`)\n    }\n    definedTags.add(tag.name)\n  })\n\n  resolved.name = typeof options.name === 'string'\n    ? options.name\n    : (options.name?.label || '')\n\n  resolved.color = typeof options.name !== 'string' ? options.name?.color : undefined","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/config/resolveConfig.ts#L281-L317","documentation":"Tag names cannot contain any of `! ( ) * & |` because those characters are operators in Vitest's tag filter expression grammar (`!not`, `&and`, `|or`, `*` wildcard, parentheses grouping). Allowing them in a name would make filter expressions ambiguous, so they are rejected outright.","triggerScenarios":"`{ name: 'flaky!' }`, `{ name: 'a*b' }`, `{ name: 'core&api' }`, `{ name: '(smoke)' }`, `{ name: 'a|b' }`.","commonSituations":"Reusing labels from another system that permits these chars; building names from CI branch names that contain `*` or `&`; copy-paste that includes markdown emphasis (`**bold**`).","solutions":["Strip or replace the reserved chars: use `core-api` instead of `core&api`.","Validate names against the allowed set: `/^[^!()*&|\\s]+$/`.","If you need logical grouping at filter time, use the operators in the CLI expression, not in the tag name."],"exampleFix":"// before\nexport default defineConfig({ test: { tags: [{ name: 'core&api' }] } })\n\n// after\nexport default defineConfig({ test: { tags: [{ name: 'core-api' }] } })","handlingStrategy":"validation","validationCode":"const RESERVED = /[!()*&|]/\nfunction assertSafeTagName(name: string): void {\n  if (RESERVED.test(name)) {\n    throw new Error(`Tag name \"${name}\" contains reserved filter-expression chars`)\n  }\n}\n\nrawTags.forEach(t => assertSafeTagName(t.name))","typeGuard":"function isFilterSafeName(name: string): boolean {\n  return typeof name === 'string' && !/[!()*&|]/.test(name)\n}","tryCatchPattern":null,"preventionTips":["Restrict tag names to letters, digits, `-`, `_`.","Sanitize names derived from CI branch names or external taxonomies.","Reserve `! & | ( ) *` for filter expressions only."],"tags":["config","tags","validation","filter-expression","naming"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}