handlebars-lang/handlebars.js · error · Exception

Arg not supported with multiple decorators

Error message

Arg not supported with multiple decorators

What it means

Thrown by HandlebarsEnvironment.registerDecorator when a caller passes both a hash/object of decorator registrations (name is an object, so multiple decorators are being registered via extend) and a second function argument. The object form of registration accepts only the decorator map; supplying a fn alongside it is unsupported, so the environment rejects the call rather than silently ignoring the fn. Fix by either passing a single name/function pair or passing only the object without a second argument.

Source

Thrown at lib/handlebars/base.js:73

    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`
        );
      }
      this.partials[name] = partial;
    }
  },
  unregisterPartial: function (name) {
    delete this.partials[name];
  },

  registerDecorator: function (name, fn) {
    if (toString.call(name) === objectType) {
      if (fn) {
        throw new Exception('Arg not supported with multiple decorators');
      }
      extend(this.decorators, name);
    } else {
      this.decorators[name] = fn;
    }
  },
  unregisterDecorator: function (name) {
    delete this.decorators[name];
  },
  /**
   * Reset the memory of illegal property accesses that have already been logged.
   * @deprecated should only be used in handlebars test-cases
   */
  resetLoggedPropertyAccesses() {
    resetLoggedProperties();
  },
};

View on GitHub (pinned to 13a7a67991)

Solutions

  1. Drop the second argument when passing a decorators object.
  2. For a single decorator, pass a string name first: registerDecorator('name', fn).

Example fix

// before
Handlebars.registerDecorator({inline: myDecorator}, other);
// after
Handlebars.registerDecorator({inline: myDecorator});
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

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

Prevention

When it happens

Trigger: Handlebars.registerDecorator({a: d1, b: d2}, extraFn) — object first arg with truthy second arg.

Common situations: Copy-paste from registerHelper single-name form; mixing bulk and single registration styles in one call.

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/780d4350a1f4da89. Report an issue: GitHub.