{"record":{"id":"c7a6a0f2bbc2a0f4","repo":"handlebars-lang/handlebars.js","slug":"arg-not-supported-with-multiple-helpers","errorCode":null,"errorMessage":"Arg not supported with multiple helpers","messagePattern":"Arg not supported with multiple helpers","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"lib/handlebars/base.js","lineNumber":43,"sourceCode":"export function HandlebarsEnvironment(helpers, partials, decorators) {\n  this.helpers = helpers || {};\n  this.partials = partials || {};\n  this.decorators = decorators || {};\n\n  registerDefaultHelpers(this);\n  registerDefaultDecorators(this);\n}\n\nHandlebarsEnvironment.prototype = {\n  constructor: HandlebarsEnvironment,\n\n  logger: logger,\n  log: logger.log,\n\n  registerHelper: function (name, fn) {\n    if (toString.call(name) === objectType) {\n      if (fn) {\n        throw new Exception('Arg not supported with multiple helpers');\n      }\n      extend(this.helpers, name);\n    } else {\n      this.helpers[name] = fn;\n    }\n  },\n  unregisterHelper: function (name) {\n    delete this.helpers[name];\n  },\n\n  registerPartial: function (name, partial) {\n    if (toString.call(name) === objectType) {\n      extend(this.partials, name);\n    } else {\n      if (typeof partial === 'undefined') {\n        throw new Exception(\n          `Attempting to register a partial called \"${name}\" as undefined`\n        );","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/handlebars-lang/handlebars.js/blob/13a7a679910d2adbfe7f6fad61ce8f98426b0378/lib/handlebars/base.js#L25-L61","documentation":"registerHelper throws this when called with an object of multiple helpers (first arg is an object) but a second argument `fn` is also passed. The multi-helper form takes only the object; a trailing function is ambiguous and rejected.","triggerScenarios":"Handlebars.registerHelper({a: fn1, b: fn2}, someFn) — object first arg with a non-null second arg.","commonSituations":"Refactoring from single-helper calls to bulk registration but leaving the old callback/function argument in place; copy-paste mixing the two call signatures.","solutions":["Remove the second argument when registering multiple helpers via an object.","If you meant to register one helper, pass a string name first: registerHelper('name', fn).","Upgrade notes: older Handlebars versions tolerated different signatures; align with the current API."],"exampleFix":"// before\nHandlebars.registerHelper({upper: s => s.toUpperCase()}, logFn);\n// after\nHandlebars.registerHelper({upper: s => s.toUpperCase()});","handlingStrategy":"validation","validationCode":"function safeRegisterHelpers(hb, nameOrMap, fn) {\n  if (typeof nameOrMap === 'object' && nameOrMap !== null && fn !== undefined) {\n    throw new TypeError('Do not pass a second arg when bulk-registering helpers');\n  }\n  hb.registerHelper(nameOrMap, fn);\n}","typeGuard":"const isHelperMap = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);","tryCatchPattern":null,"preventionTips":["Use one registration style per call: string+fn OR object, never both.","Wrap registration in a small helper that validates the arity."],"tags":["api-misuse","helpers","argument-error"],"backgroundTag":"invalid-argument","analyzedSha":"13a7a679910d2adbfe7f6fad61ce8f98426b0378","analyzedAt":"2026-09-02T20:25:07.518Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}