{"record":{"id":"761f39a0095a69f7","repo":"dianping/cat","slug":"prompt-requires-a-title","errorCode":null,"errorMessage":"prompt requires a title","messagePattern":"prompt requires a title","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cat-home/src/main/webapp/assets/js/uncompressed/bootbox.js","lineNumber":436,"sourceCode":"\n          // we assume that checkboxes are always multiple,\n          // hence we default to an empty array\n          value = [];\n\n          each(checkedItems, function(_, item) {\n            value.push($(item).val());\n          });\n          break;\n      }\n\n      return options.callback(value);\n    };\n\n    options.show = false;\n\n    // prompt specific validation\n    if (!options.title) {\n      throw new Error(\"prompt requires a title\");\n    }\n\n    if (!$.isFunction(options.callback)) {\n      throw new Error(\"prompt requires a callback\");\n    }\n\n    if (!templates.inputs[options.inputType]) {\n      throw new Error(\"invalid prompt type\");\n    }\n\n    // create the input based on the supplied type\n    input = $(templates.inputs[options.inputType]);\n\n    switch (options.inputType) {\n      case \"text\":\n      case \"textarea\":\n      case \"email\":\n      case \"date\":","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/uncompressed/bootbox.js#L418-L454","documentation":"bootbox.prompt validates that a title is present before rendering a prompt. Because prompt dialogs have no message field, the title doubles as the prompt's descriptive text ('Please enter your name:'), so an empty or missing title leaves the dialog with no visible question — hence a hard requirement.","triggerScenarios":"bootbox.prompt(callback) (forgot the title string); bootbox.prompt({callback: fn}) with no title; title built from a variable that is '' or undefined (empty model field, missing i18n key).","commonSituations":"Assuming prompt's first argument is the default value or the placeholder; migrating from a different prompt API where the question goes in message; localizing dialogs and the title key is absent for one locale.","solutions":["Pass the title as the first argument: bootbox.prompt('Enter your name:', function(result){ ... });","Or use the options form with title: bootbox.prompt({title: 'Enter your name:', callback: fn, value: defaultValue}).","Default the title when built dynamically: {title: question || 'Enter a value:'}."],"exampleFix":"// before\nbootbox.prompt(function (name) { if (name) saveName(name); });\n\n// after\nbootbox.prompt('Enter your name:', function (name) { if (name) saveName(name); });","handlingStrategy":"validation","validationCode":"bootbox.prompt(question || 'Please enter a value:', callback);\n// or options form:\nbootbox.prompt({ title: question || 'Enter a value:', callback: callback });","typeGuard":"function hasPromptTitle(o) {\n  return !!o && !!o.title;\n}","tryCatchPattern":null,"preventionTips":["prompt's first argument is the title/question","Default localized titles when i18n keys may be missing","prompt has no message property — title carries the question"],"tags":["bootbox","prompt","title","required-field"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}