handlebars-lang/handlebars.js · error · Exception

Arg not supported with multiple helpers

Error message

Arg not supported with multiple helpers

What it means

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.

Source

Thrown at lib/handlebars/base.js:43

export function HandlebarsEnvironment(helpers, partials, decorators) {
  this.helpers = helpers || {};
  this.partials = partials || {};
  this.decorators = decorators || {};

  registerDefaultHelpers(this);
  registerDefaultDecorators(this);
}

HandlebarsEnvironment.prototype = {
  constructor: HandlebarsEnvironment,

  logger: logger,
  log: logger.log,

  registerHelper: function (name, fn) {
    if (toString.call(name) === objectType) {
      if (fn) {
        throw new Exception('Arg not supported with multiple helpers');
      }
      extend(this.helpers, name);
    } else {
      this.helpers[name] = fn;
    }
  },
  unregisterHelper: function (name) {
    delete this.helpers[name];
  },

  registerPartial: function (name, partial) {
    if (toString.call(name) === objectType) {
      extend(this.partials, name);
    } else {
      if (typeof partial === 'undefined') {
        throw new Exception(
          `Attempting to register a partial called "${name}" as undefined`
        );

View on GitHub (pinned to 13a7a67991)

Solutions

  1. Remove the second argument when registering multiple helpers via an object.
  2. If you meant to register one helper, pass a string name first: registerHelper('name', fn).
  3. Upgrade notes: older Handlebars versions tolerated different signatures; align with the current API.

Example fix

// before
Handlebars.registerHelper({upper: s => s.toUpperCase()}, logFn);
// after
Handlebars.registerHelper({upper: s => s.toUpperCase()});
Defensive patterns

Strategy: validation

Validate before calling

function safeRegisterHelpers(hb, nameOrMap, fn) {
  if (typeof nameOrMap === 'object' && nameOrMap !== null && fn !== undefined) {
    throw new TypeError('Do not pass a second arg when bulk-registering helpers');
  }
  hb.registerHelper(nameOrMap, fn);
}

Type guard

const isHelperMap = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);

Prevention

When it happens

Trigger: Handlebars.registerHelper({a: fn1, b: fn2}, someFn) — object first arg with a non-null second arg.

Common situations: Refactoring from single-helper calls to bulk registration but leaving the old callback/function argument in place; copy-paste mixing the two call signatures.

Understand the failure class

Background: "must be a positive integer", "cannot be empty", "invalid argument": how invalid-argument errors work across open-source libraries — this error's family across 33 libraries.

Related errors


AI-assisted analysis of handlebars-lang/handlebars.js@13a7a67991 (2026-09-02). Data as JSON: /api/errors/c7a6a0f2bbc2a0f4. Report an issue: GitHub.