{"record":{"id":"a92daa33e369dfac","repo":"vitest-dev/vitest","slug":"tag-name-tag-name-is-invalid-tag-names-canno-a92daa","errorCode":null,"errorMessage":"Tag name \"${tag.name}\" is invalid. Tag names cannot be a logical operator like \"and\", \"or\", \"not\".","messagePattern":"Tag name \"(.+?)\" is invalid\\. Tag names cannot be a logical operator like \"and\", \"or\", \"not\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/config/resolveConfig.ts","lineNumber":302,"sourceCode":"\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\n\n  if (resolved.environment === 'browser') {\n    throw new Error(`Looks like you set \"test.environment\" to \"browser\". To enable Browser Mode, use \"test.browser.enabled\" instead.`)","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/config/resolveConfig.ts#L284-L320","documentation":"Tag names cannot be the reserved logical operators `and`, `or`, `not` (case-insensitive, whitespace-trimmed). These words are keywords in Vitest's tag filter expression grammar, so using one as a tag name would collide with operator tokenisation.","triggerScenarios":"`{ name: 'and' }`, `{ name: 'OR' }`, `{ name: ' not ' }`, or any case variant matching `^\\s*(?:and|or|not)\\s*$`.","commonSituations":"Naming tags after domain concepts that happen to be these words; auto-generating tags from a taxonomy that includes operator-like terms.","solutions":["Pick a non-reserved name: `logical-and`, `or-check`, `negated`.","Namespace the tag: `myteam.and`.","Validate names against the reserved list before exporting config."],"exampleFix":"// before\nexport default defineConfig({ test: { tags: [{ name: 'or' }] } })\n\n// after\nexport default defineConfig({ test: { tags: [{ name: 'or-gate' }] } })","handlingStrategy":"validation","validationCode":"const RESERVED_WORDS = /^\\s*(?:and|or|not)\\s*$/i\nfunction assertNotReservedWord(name: string): void {\n  if (RESERVED_WORDS.test(name)) {\n    throw new Error(`Tag name \"${name}\" is a reserved logical operator`)\n  }\n}\n\nrawTags.forEach(t => assertNotReservedWord(t.name))","typeGuard":"function isNonReservedName(name: string): boolean {\n  return typeof name === 'string' && !/^\\s*(?:and|or|not)\\s*$/i.test(name)\n}","tryCatchPattern":null,"preventionTips":["Namespace tag names to avoid accidental collisions with operators.","Maintain a denylist of reserved words when generating tags programmatically.","Prefer domain-specific names over generic logical terms."],"tags":["config","tags","validation","filter-expression","reserved-word"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}