eythaann/Seelen-UI · error · Error

The inner array cannot be null or undefined.

Error message

The inner array cannot be null or undefined.

What it means

The List class wraps an internal array and validates it in its constructor. Passing null or undefined as the inner array makes every later operation on the List meaningless, so the constructor throws immediately with this message.

Source

Thrown at libs/core/src/utils/List.ts:13

/**
 * 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.
   */

View on GitHub (pinned to dee4aaa940)

Solutions

  1. Coerce to an array at the call site before constructing: new List(value ?? []).
  2. Validate the source data (schema or Array.isArray check) before wrapping it in List.
  3. Fix the upstream producer so empty results are [] instead of null/undefined.
  4. Give parameters that feed List a default: function make(items: T[] = []).

Example fix

// before: const list = new List(items); // items may be undefined
// after: const list = new List(items ?? []);
Defensive patterns

Strategy: validation

Validate before calling

if (value == null) throw new Error('cannot build List from null/undefined'); const list = new List(value ?? []);

Type guard

function isArrayish<T>(v: T[] | null | undefined): v is T[] { return v != null; }

Try / catch

let list: List<T>; try { list = new List(maybeItems); } catch (e) { if (e instanceof Error && e.message.includes('cannot be null or undefined')) { list = new List([]); } else { throw e; } }

Prevention

When it happens

Trigger: new List(null) or new List(undefined) directly; more commonly new List(someMaybeUndefined) where the value came from an optional lookup (find(), map.get()), an unvalidated API/IPC response, a missing object property, or a parameter without a default.

Common situations: Reading a property that does not exist (data.items when items is absent); a backend command returning null for an empty collection; passing find()/get() results straight into List; JSON payloads missing expected fields.

Related errors


AI-assisted analysis of eythaann/Seelen-UI@dee4aaa940 (2026-09-03). Data as JSON: /api/errors/4127397d1afb7b57. Report an issue: GitHub.