dianping/cat · error · Error
invalid prompt type
Error message
invalid prompt type
What it means
bootbox.prompt only accepts input types for which it ships an HTML template (in this version: text, textarea, email, date, time, number, password, select, and later checkbox). The templates.inputs lookup happens before the input element is created, and an unknown inputType throws 'invalid prompt type'.
Source
Thrown at cat-home/src/main/webapp/assets/js/uncompressed/bootbox.js:444
break;
}
return options.callback(value);
};
options.show = false;
// prompt specific validation
if (!options.title) {
throw new Error("prompt requires a title");
}
if (!$.isFunction(options.callback)) {
throw new Error("prompt requires a callback");
}
if (!templates.inputs[options.inputType]) {
throw new Error("invalid prompt type");
}
// create the input based on the supplied type
input = $(templates.inputs[options.inputType]);
switch (options.inputType) {
case "text":
case "textarea":
case "email":
case "date":
case "time":
case "number":
case "password":
input.val(options.value);
break;
case "select":
var groups = {};View on GitHub (pinned to e815e74d4c)
Solutions
- Restrict inputType to the types your bundled bootbox version supports — check templates.inputs in the shipped uncompressed/bootbox.js for the authoritative list.
- For unsupported types, use bootbox.dialog with custom HTML in the message, or fall back to a plain form.
- Normalize the value: inputType: (type || 'text').toLowerCase() — guards against typos and missing defaults.
Example fix
// before
bootbox.prompt({ title: 'Pick a color', inputType: 'color', callback: fn });
// after
bootbox.prompt({ title: 'Favorite color', inputType: 'text', value: '#ff0000', callback: fn }); Defensive patterns
Strategy: validation
Validate before calling
var SUPPORTED = ['text','textarea','email','date','time','number','password','select','checkbox']; var type = (opts.inputType || 'text').toLowerCase(); if (SUPPORTED.indexOf(type) === -1) type = 'text'; opts.inputType = type; bootbox.prompt(opts);
Type guard
function isSupportedInputType(t) {
return ['text','textarea','email','date','time','number','password','select','checkbox'].indexOf(t) !== -1;
} Prevention
- Check templates.inputs in the bundled bootbox.js for the exact supported list
- Pin the bootbox version — supported types differ across releases
- For unsupported input types use bootbox.dialog with custom HTML
When it happens
Trigger: bootbox.prompt({title: 'Pick', inputType: 'radio', callback: fn}); inputType: 'color', 'file', 'range', 'datetime-local', or leaving inputType undefined in a version where 'text' is not the default key present in templates.inputs.
Common situations: Expecting bootbox to mirror the full HTML5 input type list; version drift — upgrading bootbox changed the supported set (checkbox added in 4.3+, removed/renamed types across versions); typos in the type string ('Text', 'textarea ' with whitespace).
Related errors
- given options in wrong format
- Please supply an object of options
- Please specify a message
- button with key {key} must be an object
- button key {key} is not allowed (options are {buttons})
AI-assisted analysis of dianping/cat@e815e74d4c (2026-08-14).
Data as JSON: /api/errors/5aa381ffb64e7cfd.
Report an issue: GitHub.