eythaann/Seelen-UI · error · Error
The inner array must be an array.
Error message
The inner array must be an array.
What it means
After the null check, List's constructor verifies with Array.isArray that the inner value is actually an array. Passing a non-array value (string, plain object, Set/Map, typed array) is rejected because List relies on array semantics for its internal storage.
Source
Thrown at libs/core/src/utils/List.ts:16
/**
* A generic, abstract class for managing an array-like collection of items.
* @template T The type of elements stored in the list.
*/
export abstract class List<T = unknown> {
/**
* Constructor for the List class.
* @param inner The internal array that stores the elements.
* @throws Error if the provided array is not
*/
constructor(protected inner: T[]) {
if (!inner) {
throw new Error("The inner array cannot be null or undefined.");
}
if (!Array.isArray(inner)) {
throw new Error("The inner array must be an array.");
}
}
public [Symbol.iterator](): Iterable<T> {
return this.inner[Symbol.iterator]();
}
public get length(): number {
return this.inner.length;
}
/**
* Provides direct access to the internal array of items.
* @returns A reference to the internal array of items.
*/
public asArray(): T[] {
return this.inner;
}View on GitHub (pinned to dee4aaa940)
Solutions
- Ensure you pass an actual array: new List(Array.isArray(x) ? x : []) or Object.values(x) for map-like objects.
- Remove unsafe `as T[]` casts and type the source properly so TypeScript flags non-arrays.
- Validate/parse incoming data with a schema (zod/yup) that asserts an array before constructing List.
- Spread iterables into arrays: new List([...setOrIterable]).
Example fix
// before: const list = new List(response.items as string[]); // actually an object // after: const items = Array.isArray(response.items) ? response.items : []; const list = new List(items);
Defensive patterns
Strategy: type-guard
Validate before calling
if (!Array.isArray(items)) throw new TypeError('List requires a real array, got: ' + typeof items); const list = new List(items); Type guard
function is_array<T>(v: unknown): v is T[] { return Array.isArray(v); } Try / catch
let list: List<T>; try { list = new List(untrusted as T[]); } catch (e) { if (e instanceof Error && e.message.includes('must be an array')) { list = new List(Object.values(untrusted as Record<string, T>)); } else { throw e; } } Prevention
- Avoid `as T[]` casts on untrusted data; use Array.isArray narrowing.
- Wrap iterables/Sets/Maps with [...iterable] before constructing List.
- Schema-validate external payloads so arrays are arrays at runtime.
- When a producer changes shape, update all List consumers.
When it happens
Trigger: new List({} | 'abc' | someSet | someMap) — passing an object, string, or other non-array collection; passing a value typed as T[] at compile time via an unsafe cast or any-typed API data that is not an array at runtime.
Common situations: Unsafe `data as T[]` casts hiding that the API returned an object whose data field holds the real array; passing a single element instead of an array; refactors changing a producer from array to object without updating consumers.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
AI-assisted analysis of eythaann/Seelen-UI@dee4aaa940 (2026-09-03).
Data as JSON: /api/errors/941365d12332dad2.
Report an issue: GitHub.