{"record":{"id":"6c9bc15c8cb960fd","repo":"dianping/cat","slug":"invalid-argument-length","errorCode":null,"errorMessage":"Invalid argument length","messagePattern":"Invalid argument length","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cat-home/src/main/webapp/assets/js/uncompressed/bootbox.js","lineNumber":207,"sourceCode":"\n    return options;\n  }\n\n  /**\n   * map a flexible set of arguments into a single returned object\n   * if args.length is already one just return it, otherwise\n   * use the properties argument to map the unnamed args to\n   * object properties\n   * so in the latter case:\n   * mapArguments([\"foo\", $.noop], [\"message\", \"callback\"])\n   * -> { message: \"foo\", callback: $.noop }\n   */\n  function mapArguments(args, properties) {\n    var argn = args.length;\n    var options = {};\n\n    if (argn < 1 || argn > 2) {\n      throw new Error(\"Invalid argument length\");\n    }\n\n    if (argn === 2 || typeof args[0] === \"string\") {\n      options[properties[0]] = args[0];\n      options[properties[1]] = args[1];\n    } else {\n      options = args[0];\n    }\n\n    return options;\n  }\n\n  /**\n   * merge a set of default dialog options with user supplied arguments\n   */\n  function mergeArguments(defaults, args, properties) {\n    return $.extend(\n      // deep merge","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/uncompressed/bootbox.js#L189-L225","documentation":"mapArguments converts the convenience argument forms of alert/confirm/prompt into a single options object. It accepts exactly 1 or 2 arguments: either (options) or (str/prim, callback). Zero arguments, or three or more, throw 'Invalid argument length' before any dialog is created.","triggerScenarios":"bootbox.alert() with no arguments; bootbox.confirm('Proceed?', yesFn, noFn) — confirm supports only one callback (both outcomes go through it); forwarding an arguments object or spread of unknown length into a bootbox wrapper: bootbox.alert.apply(null, args).","commonSituations":"Copy-pasting from a two-callback dialog API (jQuery UI, native confirm patterns) into bootbox; a wrapper function using .apply with caller-controlled args; forgetting the message argument in a cleanup/dead code path that still executes.","solutions":["Pass at most (message, callback): bootbox.confirm('Proceed?', function(result){ ... }) — branch on the boolean result inside.","Pass a single options object when you need more configuration: bootbox.confirm({message: '...', callback: fn, title: '...'}).","If wrapping bootbox dynamically, normalize first: pick the first 1-2 meaningful args or build an options object yourself."],"exampleFix":"// before\nbootbox.confirm('Delete this record?', function () { remove(); }, function () {});\n\n// after\nbootbox.confirm('Delete this record?', function (result) { if (result) remove(); });","handlingStrategy":"validation","validationCode":"function showConfirm(msg, cb) {\n  cb = typeof cb === 'function' ? cb : null;\n  if (cb) bootbox.confirm(msg, cb); else bootbox.confirm({message: msg});\n}\n// never forward raw arguments objects of unknown length","typeGuard":"function isValidBootboxArgs(args) {\n  return args.length >= 1 && args.length <= 2 &&\n    (typeof args[0] === 'string' || (args[0] && typeof args[0] === 'object'));\n}","tryCatchPattern":null,"preventionTips":["alert/confirm/prompt accept at most (text, callback)","Build an options object when more configuration is needed","Normalize before .apply-ing dynamic arguments"],"tags":["bootbox","dialog","api-misuse","arguments"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}