{"record":{"id":"dfb6da4f055bf244","repo":"hexojs/hexo","slug":"name-is-required-dfb6da","errorCode":null,"errorMessage":"name is required","messagePattern":"name is required","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/extend/migrator.ts","lineNumber":32,"sourceCode":" * A migrator helps users migrate from other systems to Hexo.\n */\nclass Migrator {\n  public store: Store;\n\n  constructor() {\n    this.store = {};\n  }\n\n  list(): Store {\n    return this.store;\n  }\n\n  get(name: string): StoreFunction {\n    return this.store[name];\n  }\n\n  register(name: string, fn: (this: Hexo, args: any, callback?: NodeJSLikeCallback<any>) => any): 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 (fn.length > 1) {\n      fn = Promise.promisify(fn);\n    } else {\n      fn = Promise.method(fn);\n    }\n\n    this.store[name] = fn;\n  }\n}\n\nexport = Migrator;\n","sourceCodeStart":14,"sourceCodeEnd":46,"githubUrl":"https://github.com/hexojs/hexo/blob/059cb17494d0632a053c24077f5bcb6ae92acc51/lib/extend/migrator.ts#L14-L46","documentation":"Thrown by Migrator.register when the 'name' argument is falsy. Migrators import content from other platforms and are selected by name on the CLI; an empty name makes the migrator unusable.","triggerScenarios":"Calling hexo.extend.migrator.register('', fn) or register(undefined, fn).","commonSituations":"A migrator plugin reads its name from a package field that is empty, or passes a variable that was never assigned.","solutions":["Pass a non-empty migrator name string.","Validate the name source before registering.","Ensure the name is unique among registered migrators."],"exampleFix":"// before\nhexo.extend.migrator.register(name, fn);\n// after\nif (name) hexo.extend.migrator.register(name, fn);","handlingStrategy":"validation","validationCode":"if (!name) throw new Error('migrator name required');\nhexo.extend.migrator.register(name, fn);","typeGuard":"const isValidName = (n: unknown): n is string => typeof n === 'string' && n.length > 0;","tryCatchPattern":null,"preventionTips":["Hard-code migrator names as constants.","Validate name before registering in a shared helper.","Test the migrator is selectable via hexo.extend.migrator.get(name)."],"tags":["migrator","validation","plugin"],"backgroundTag":null,"analyzedSha":"059cb17494d0632a053c24077f5bcb6ae92acc51","analyzedAt":"2026-08-12T20:52:05.731Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}