{"record":{"id":"a287fd05c91baf95","repo":"OrchardCMS/OrchardCore","slug":"regexp-exec-method-returned-something-other-than-an-object","errorCode":null,"errorMessage":"RegExp exec method returned something other than an Object or null","messagePattern":"RegExp exec method returned something other than an Object or null","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/vue-draggable-2.24.3/vuedraggable.common.js","lineNumber":869,"sourceCode":"/***/ }),\n\n/***/ \"5f1b\":\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar classof = __webpack_require__(\"23c6\");\nvar builtinExec = RegExp.prototype.exec;\n\n // `RegExpExec` abstract operation\n// https://tc39.github.io/ecma262/#sec-regexpexec\nmodule.exports = function (R, S) {\n  var exec = R.exec;\n  if (typeof exec === 'function') {\n    var result = exec.call(R, S);\n    if (typeof result !== 'object') {\n      throw new TypeError('RegExp exec method returned something other than an Object or null');\n    }\n    return result;\n  }\n  if (classof(R) !== 'RegExp') {\n    throw new TypeError('RegExp#exec called on incompatible receiver');\n  }\n  return builtinExec.call(R, S);\n};\n\n\n/***/ }),\n\n/***/ \"613b\":\n/***/ (function(module, exports, __webpack_require__) {\n\nvar shared = __webpack_require__(\"5537\")('keys');\nvar uid = __webpack_require__(\"ca5a\");\nmodule.exports = function (key) {","sourceCodeStart":851,"sourceCodeEnd":887,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/vue-draggable-2.24.3/vuedraggable.common.js#L851-L887","documentation":"core-js's regexp-exec shim (bundled into vuedraggable.common.js) calls R.exec.call(R, S) and, per spec (RegExpExec), throws this TypeError when exec returns a non-object, non-null value (e.g. undefined, a primitive, true). It fires when code invokes a custom or patched exec whose return violates the RegExp contract, or when R is an exotic object exposing an exec method.","triggerScenarios":"Calling String.prototype.match/split/replace (internal RegExpExec) with a RegExp-like object whose exec is overridden to return undefined or a primitive; passing an object with a bogus `exec` function into code paths used by vuedraggable (e.g. drag-handle selectors or internal string parsing); monkey-patching RegExp.prototype.exec incorrectly.","commonSituations":"Libraries or user code patching RegExp.prototype.exec to add logging and forgetting to return the result; returning `undefined` with `return;` after a guard; polyfill conflicts where an older core-js or another polyfill defines an incompatible exec; mocking RegExp in tests with a stub returning undefined.","solutions":["Find any overridden RegExp.prototype.exec (or object with custom exec) and ensure it returns the match array or null on every path (add `return null;` / `return result;`).","Search the bundle/app for `RegExp.prototype.exec =` and `.exec =` patches; remove or fix the monkey-patch.","Check for duplicate/conflicting core-js or RegExp polyfills loaded before vuedraggable; align polyfill versions.","If passing a RegExp-like object, use a real RegExp instance instead.","Fix test mocks so exec stubs return an array (e.g. ['match']) or null, never undefined."],"exampleFix":"// before\nconst origExec = RegExp.prototype.exec;\nRegExp.prototype.exec = function (s) {\n  console.log('exec', s);\n  origExec.call(this, s); // result never returned -> TypeError\n};\n// after\nconst origExec = RegExp.prototype.exec;\nRegExp.prototype.exec = function (s) {\n  const result = origExec.call(this, s);\n  console.log('exec', s, result);\n  return result;\n};","handlingStrategy":"type-guard","validationCode":"if (re instanceof RegExp === false && !(re && typeof re.exec === 'function')) throw new TypeError('Expected a RegExp (or exec-returning RegExp-like) before match/exec');","typeGuard":"function isSafeRegExp(v) { return v instanceof RegExp || (v !== null && typeof v === 'object' && typeof v.exec === 'function'); }","tryCatchPattern":"try { return str.match(re); } catch (e) { if (e instanceof TypeError && /RegExp exec/.test(e.message)) { console.warn('Bad RegExp receiver or patched exec; falling back to new RegExp(re.source, re.flags)'); return str.match(new RegExp(re.source, re.flags)); } throw e; }","preventionTips":["Never monkey-patch RegExp.prototype.exec without returning the result on every path","Avoid loading multiple/old core-js or RegExp polyfills alongside vuedraggable","Always construct real RegExp instances instead of RegExp-like plain objects","Make test mocks of exec return an array or null, never undefined","Grep the codebase for `RegExp.prototype.exec =` and `.exec =` patches during upgrades"],"tags":["regexp","core-js","polyfill","typeerror"],"backgroundTag":"unexpected-response-shape","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}