{"record":{"id":"77570a34cdc3d1db","repo":"OrchardCMS/OrchardCore","slug":"invalid-attempt-to-destructure-non-iterable-instance-in","errorCode":null,"errorMessage":"Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.","messagePattern":"Invalid attempt to destructure non-iterable instance\\.\nIn order to be iterable, non-array objects must have a \\[Symbol\\.iterator\\]\\(\\) method\\.","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":1870,"sourceCode":"  for (var i = 0, arr2 = new Array(len); i < len; i++) {\n    arr2[i] = arr[i];\n  }\n\n  return arr2;\n}\n// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js\n\nfunction _unsupportedIterableToArray(o, minLen) {\n  if (!o) return;\n  if (typeof o === \"string\") return _arrayLikeToArray(o, minLen);\n  var n = Object.prototype.toString.call(o).slice(8, -1);\n  if (n === \"Object\" && o.constructor) n = o.constructor.name;\n  if (n === \"Map\" || n === \"Set\") return Array.from(o);\n  if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);\n}\n// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js\nfunction _nonIterableRest() {\n  throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js\n\n\n\n\nfunction _slicedToArray(arr, i) {\n  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();\n}\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es7.array.includes.js\nvar es7_array_includes = __webpack_require__(\"6762\");\n\n// EXTERNAL MODULE: ./node_modules/core-js/modules/es6.string.includes.js\nvar es6_string_includes = __webpack_require__(\"2fdb\");\n\n// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js\n\nfunction _arrayWithoutHoles(arr) {","sourceCodeStart":1852,"sourceCodeEnd":1888,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/vue-draggable-2.24.3/vuedraggable.common.js#L1852-L1888","documentation":"Babel's compiled array destructuring helper (_slicedToArray -> _nonIterableRest, bundled into vuedraggable.common.js) throws this TypeError when destructuring a value that is neither an array nor iterable (no [Symbol.iterator]) — after _toArray's fallbacks (Object/Map/Set/Arguments/TypedArray) all fail to produce an array-like.","triggerScenarios":"Transpiled code doing `const [a, b] = x` where x is undefined/null, a plain non-iterable object, a number, or a DOM/foreign collection without Symbol.iterator — e.g. destructuring a result of a function that returned null, or an HTMLFormControlsCollection/old NodeList in an environment lacking iterable support patched around.","commonSituations":"Calling a helper that returns undefined on early exit and destructuring its result; JSON-parsed data assumed to be arrays but actually objects/null; using vuedraggable with a value/model that is not an array (dragging a non-list value); browser without Symbol.iterator for a specific collection type while Babel helpers assume iterability.","solutions":["Guard the source before destructuring: `const arr = Array.isArray(x) ? x : [];` then destructure.","For array-like objects (arguments, NodeLists, HTMLCollections), convert first with Array.from(x) before destructuring.","Trace which destructure site throws via the stack into vuedraggable's compiled code and fix the producing function to always return an array.","For Map/Set-like values ensure they are actually Map/Set (the helper only converts when constructor.name matches); coerce explicitly.","Fix the model passed to draggable components (e.g. v-model / list prop) so it is always an array, initializing empty lists instead of null."],"exampleFix":"// before\nconst [first, second] = getData(); // getData() may return undefined\n// after\nconst data = getData();\nconst [first, second] = Array.isArray(data) ? data : [];","handlingStrategy":"type-guard","validationCode":"if (!Array.isArray(value) && !(value && typeof value[Symbol.iterator] === 'function')) { throw new TypeError('Expected iterable/array for destructuring, got: ' + Object.prototype.toString.call(value)); }","typeGuard":"function isIterable(v) { return v != null && typeof v[Symbol.iterator] === 'function'; }","tryCatchPattern":"try { const [a, b] = value; } catch (e) { if (e instanceof TypeError && /non-iterable|iterable/.test(e.message)) { const [a, b] = Array.from(value ?? []); } else { throw e; } }","preventionTips":["Default to arrays before destructuring: `const [a] = x || []`","Convert array-likes (NodeList, arguments, HTMLCollection) with Array.from first","Ensure draggable v-model/list props are always initialized arrays, never null","Make helpers that feed destructuring always return arrays (early returns included)","Enable lint rules (prefer-const + no-unused-vars won't catch it; add runtime guards in dev builds) to catch null-returning producers early"],"tags":["babel","destructuring","iterable","typeerror"],"backgroundTag":"type-mismatch","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"}