{"record":{"id":"5754a9b13733d5f9","repo":"dianping/cat","slug":"please-specify-a-message","errorCode":null,"errorMessage":"Please specify a message","messagePattern":"Please specify a message","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cat-home/src/main/webapp/assets/js/uncompressed/bootbox.js","lineNumber":141,"sourceCode":"  }\n\n  function each(collection, iterator) {\n    var index = 0;\n    $.each(collection, function(key, value) {\n      iterator(key, value, index++);\n    });\n  }\n\n  function sanitize(options) {\n    var buttons;\n    var total;\n\n    if (typeof options !== \"object\") {\n      throw new Error(\"Please supply an object of options\");\n    }\n\n    if (!options.message) {\n      throw new Error(\"Please specify a message\");\n    }\n\n    // make sure any supplied options take precedence over defaults\n    options = $.extend({}, defaults, options);\n\n    if (!options.buttons) {\n      options.buttons = {};\n    }\n\n    // we only support Bootstrap's \"static\" and false backdrop args\n    // supporting true would mean you could dismiss the dialog without\n    // explicitly interacting with it\n    options.backdrop = options.backdrop ? \"static\" : false;\n\n    buttons = options.buttons;\n\n    total = getKeyLength(buttons);\n","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/uncompressed/bootbox.js#L123-L159","documentation":"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.","triggerScenarios":"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: ''}.","commonSituations":"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.","solutions":["Always set a message, even a fallback: {message: msg || 'No details available.'}.","If the dialog should be skipped entirely when there is nothing to say, guard before calling: if (!msg) return;","Check the property name — it must be message, not text/content/body (this bootbox version)."],"exampleFix":"// before\nbootbox.dialog({ title: 'Errors', message: errors.join(', ') }); // '' when list empty\n\n// after\nbootbox.dialog({ title: 'Errors', message: errors.join(', ') || 'No errors.' });","handlingStrategy":"validation","validationCode":"if (!opts || typeof opts.message !== 'string' || !opts.message.length) {\n  opts = opts || {};\n  opts.message = fallbackText || 'No message provided.';\n}\nbootbox.dialog(opts);","typeGuard":"function hasBootboxMessage(o) {\n  return !!o && !!o.message;\n}","tryCatchPattern":null,"preventionTips":["Always provide a message key in dialog options","Default dynamic messages: msg || 'No details available.'","Distinguish message (required) from title (optional)"],"tags":["bootbox","dialog","validation","required-field"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}