{"record":{"id":"607f8e74993dbf14","repo":"hexojs/hexo","slug":"entry-is-required","errorCode":null,"errorMessage":"entry is required","messagePattern":"entry is required","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/extend/injector.ts","lineNumber":50,"sourceCode":"    return this.store;\n  }\n\n  get(entry: Entry, to = 'default'): any[] {\n    return Array.from(this.store[entry][to] || []);\n  }\n\n  getText(entry: Entry, to = 'default'): string {\n    const arr = this.get(entry, to);\n    if (!arr || !arr.length) return '';\n    return arr.join('');\n  }\n\n  getSize(entry: Entry): number {\n    return this.cache.apply(`${entry}-size`, () => Object.keys(this.store[entry]).length) as number;\n  }\n\n  register(entry: Entry, value: string | (() => string), to = 'default'): void {\n    if (!entry) throw new TypeError('entry is required');\n    if (typeof value === 'function') value = value();\n\n    const entryMap = this.store[entry] || this.store.head_end;\n    const valueSet = entryMap[to] || new Set();\n    valueSet.add(value);\n    entryMap[to] = valueSet;\n  }\n\n  _getPageType(pageLocals): string {\n    let currentType = 'default';\n    if (pageLocals.__index) currentType = 'home';\n    if (pageLocals.__post) currentType = 'post';\n    if (pageLocals.__page) currentType = 'page';\n    if (pageLocals.archive) currentType = 'archive';\n    if (pageLocals.category) currentType = 'category';\n    if (pageLocals.tag) currentType = 'tag';\n    if (pageLocals.layout) currentType = pageLocals.layout;\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/hexojs/hexo/blob/059cb17494d0632a053c24077f5bcb6ae92acc51/lib/extend/injector.ts#L32-L68","documentation":"Thrown by Injector.register when the 'entry' argument is falsy. The injector inserts content into page injection points (head_begin, head_end, body_begin, body_end); the entry selects where the value is injected.","triggerScenarios":"Calling hexo.extend.injector.register('', '<style/>') or register(undefined, value).","commonSituations":"A theme/plugin computes the injection point from page metadata that is empty, or a typo leaves entry unset.","solutions":["Pass one of the valid Entry values (head_begin/head_end/body_begin/body_end) as the first argument.","Default the entry to a valid point when it comes from dynamic logic.","Guard against falsy entry before registering."],"exampleFix":"// before\nhexo.extend.injector.register(point, '<meta/>');\n// after\nhexo.extend.injector.register(point || 'head_end', '<meta/>');","handlingStrategy":"validation","validationCode":"const ENTRIES = ['head_begin','head_end','body_begin','body_end'] as const;\nif (!ENTRIES.includes(entry)) throw new Error('invalid injector entry');\nhexo.extend.injector.register(entry, value);","typeGuard":"type Entry = 'head_begin'|'head_end'|'body_begin'|'body_end';\nconst isEntry = (e: unknown): e is Entry => typeof e === 'string' && ['head_begin','head_end','body_begin','body_end'].includes(e);","tryCatchPattern":null,"preventionTips":["Constrain entry to the four known injection points via a union type.","Default dynamic entries to a safe value like 'head_end'.","Validate entry against the allowed list before registering."],"tags":["injector","validation","plugin"],"backgroundTag":null,"analyzedSha":"059cb17494d0632a053c24077f5bcb6ae92acc51","analyzedAt":"2026-08-12T20:52:05.731Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}