{"record":{"id":"c30536cb27821fca","repo":"hexojs/hexo","slug":"name-is-required-c30536","errorCode":null,"errorMessage":"name is required","messagePattern":"name is required","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/extend/tag.ts","lineNumber":220,"sourceCode":"\n/**\n * A tag allows users to quickly and easily insert snippets into their posts.\n */\nclass Tag {\n  public env: Environment;\n  public source: string;\n\n  constructor() {\n    this.env = new Environment(null, {\n      autoescape: false\n    });\n  }\n\n  register(name: string, fn: TagFunction): void\n  register(name: string, fn: TagFunction, ends: boolean): void\n  register(name: string, fn: TagFunction, options: RegisterOptions): void\n  register(name: string, fn: TagFunction, options?: RegisterOptions | boolean):void {\n    if (!name) throw new TypeError('name is required');\n    if (typeof fn !== 'function') throw new TypeError('fn must be a function');\n\n    if (options == null || typeof options === 'boolean') {\n      options = { ends: options as boolean };\n    }\n\n    let tag: NunjucksTag;\n\n    if (options.async) {\n      let asyncFn: AsyncTagFunction;\n      if (fn.length > 2) {\n        asyncFn = Promise.promisify(fn);\n      } else {\n        asyncFn = Promise.method(fn);\n      }\n\n      if (options.ends) {\n        tag = new NunjucksAsyncBlock(name, asyncFn);","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/hexojs/hexo/blob/059cb17494d0632a053c24077f5bcb6ae92acc51/lib/extend/tag.ts#L202-L238","documentation":"Thrown by Tag.register when the 'name' argument is falsy. Tags are custom template tags (e.g. blockquote, codepen) added to the Nunjucks environment by name; an empty name cannot be registered as a Nunjucks extension.","triggerScenarios":"Calling hexo.extend.tag.register('', fn) or register(undefined, fn).","commonSituations":"A tag plugin reads its name from a config field that is empty, or a loop registers tags from a partial map producing undefined keys.","solutions":["Pass a non-empty tag name string.","Validate the name source before registering.","Ensure the name is a valid Nunjucks extension identifier."],"exampleFix":"// before\nhexo.extend.tag.register(tagName, fn);\n// after\nif (tagName) hexo.extend.tag.register(tagName, fn);","handlingStrategy":"validation","validationCode":"if (!name) throw new Error('tag name required');\nhexo.extend.tag.register(name, fn);","typeGuard":"const isValidName = (n: unknown): n is string => typeof n === 'string' && n.length > 0;","tryCatchPattern":null,"preventionTips":["Read tag names from a constant map with non-empty keys.","Validate name in a shared registerTag helper.","Test the tag is callable in a template after registration."],"tags":["tag","template","validation","plugin"],"backgroundTag":null,"analyzedSha":"059cb17494d0632a053c24077f5bcb6ae92acc51","analyzedAt":"2026-08-12T20:52:05.731Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}