dianping/cat · error · Error

Please specify a message

Error message

Please specify a message

What it means

sanitize() requires options.message to be present and non-empty — the message is the one mandatory content field of every bootbox dialog (title, buttons, etc. are all optional). This throws when the options object exists but carries no message, including when message is an empty string or undefined.

Source

Thrown at cat-home/src/main/webapp/assets/js/uncompressed/bootbox.js:141

  }

  function each(collection, iterator) {
    var index = 0;
    $.each(collection, function(key, value) {
      iterator(key, value, index++);
    });
  }

  function sanitize(options) {
    var buttons;
    var total;

    if (typeof options !== "object") {
      throw new Error("Please supply an object of options");
    }

    if (!options.message) {
      throw new Error("Please specify a message");
    }

    // make sure any supplied options take precedence over defaults
    options = $.extend({}, defaults, options);

    if (!options.buttons) {
      options.buttons = {};
    }

    // we only support Bootstrap's "static" and false backdrop args
    // supporting true would mean you could dismiss the dialog without
    // explicitly interacting with it
    options.backdrop = options.backdrop ? "static" : false;

    buttons = options.buttons;

    total = getKeyLength(buttons);

View on GitHub (pinned to e815e74d4c)

Solutions

  1. Always set a message, even a fallback: {message: msg || 'No details available.'}.
  2. If the dialog should be skipped entirely when there is nothing to say, guard before calling: if (!msg) return;
  3. Check the property name — it must be message, not text/content/body (this bootbox version).

Example fix

// before
bootbox.dialog({ title: 'Errors', message: errors.join(', ') }); // '' when list empty

// after
bootbox.dialog({ title: 'Errors', message: errors.join(', ') || 'No errors.' });
Defensive patterns

Strategy: validation

Validate before calling

if (!opts || typeof opts.message !== 'string' || !opts.message.length) {
  opts = opts || {};
  opts.message = fallbackText || 'No message provided.';
}
bootbox.dialog(opts);

Type guard

function hasBootboxMessage(o) {
  return !!o && !!o.message;
}

Prevention

When it happens

Trigger: bootbox.dialog({title: 'Confirm'}); bootbox.alert(undefined); building options dynamically where the message expression evaluates to '' (e.g. empty validation errors list joined to a string); passing {message: ''}.

Common situations: Constructing dialogs from data where the message field failed to populate (empty error array, missing localization key); refactoring where the message moved to another property; conditional code that only sets the message in one branch.

Related errors


AI-assisted analysis of dianping/cat@e815e74d4c (2026-08-14). Data as JSON: /api/errors/5754a9b13733d5f9. Report an issue: GitHub.