{"record":{"id":"e593922a3f89a5e5","repo":"hexojs/hexo","slug":"name-is-required","errorCode":null,"errorMessage":"name is required","messagePattern":"name is required","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/extend/console.ts","lineNumber":76,"sourceCode":"  }\n\n  list(): Store {\n    return this.store;\n  }\n\n  /**\n   * Register a console plugin\n   * @param {String} name - The name of console plugin to be registered\n   * @param {String} desc - More detailed information about a console command\n   * @param {Option} options - The description of each option of a console command\n   * @param {AnyFn} fn - The console plugin to be registered\n   */\n  register(name: string, fn: AnyFn): void\n  register(name: string, desc: string, fn: AnyFn): void\n  register(name: string, options: Option, fn: AnyFn): void\n  register(name: string, desc: string, options: Option, fn: AnyFn): void\n  register(name: string, desc: string | Option | AnyFn, options?: Option | AnyFn, fn?: AnyFn): void {\n    if (!name) throw new TypeError('name is required');\n\n    if (!fn) {\n      if (options) {\n        if (typeof options === 'function') {\n          fn = options;\n\n          if (typeof desc === 'object') { // name, options, fn\n            options = desc;\n            desc = '';\n          } else { // name, desc, fn\n            options = {};\n          }\n        } else {\n          throw new TypeError('fn must be a function');\n        }\n      } else {\n        // name, fn\n        if (typeof desc === 'function') {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/hexojs/hexo/blob/059cb17494d0632a053c24077f5bcb6ae92acc51/lib/extend/console.ts#L58-L94","documentation":"Thrown by Console.register when the first 'name' argument is falsy. Hexo's console extend lets plugins register CLI sub-commands identified by name; every registration overloads start with a required name. This guard stops an anonymous or mis-named command from entering the store.","triggerScenarios":"Calling hexo.extend.console.register('', fn), register(undefined, fn), or register(null, 'desc', fn).","commonSituations":"A plugin reads a command name from a config/package field that is empty or missing, or a refactor dropped the name argument, leaving an empty string.","solutions":["Provide a non-empty name string as the first argument.","If the name comes from configuration, validate it is a non-empty string before registering.","Check the plugin's registration loop is not mapping over an undefined list producing empty names."],"exampleFix":"// before\nhexo.extend.console.register(cmdName || '', fn);\n// after\nif (cmdName) hexo.extend.console.register(cmdName, fn);","handlingStrategy":"validation","validationCode":"if (!name || typeof name !== 'string') throw new Error('console command name required');\nhexo.extend.console.register(name, fn);","typeGuard":"const isValidName = (n: unknown): n is string => typeof n === 'string' && n.length > 0;","tryCatchPattern":null,"preventionTips":["Centralize plugin registration with a helper that validates name first.","Read command names from package.json and assert they are non-empty.","Add unit tests asserting every registered command has a name."],"tags":["console","cli","validation","plugin"],"backgroundTag":null,"analyzedSha":"059cb17494d0632a053c24077f5bcb6ae92acc51","analyzedAt":"2026-08-12T20:52:05.731Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}