Bug: empty folder shows "Load failed: Cannot read properties of null (reading 'length')" #71

Closed
opened 2026-07-30 02:56:20 +00:00 by Cordy · 1 comment
Owner

Dogfood finding (Nikola, 2026-07-30): opening an empty folder surfaces Load failed: Cannot read properties of null (reading 'length') instead of an empty-state.

Cause: GET /api/v1/files marshals the driver's items slice, and an empty directory yields a nil slice → "items": null in JSON, so the client's items.length throws. (storage.Driver.List returns nil, nil in several drivers rather than an empty slice.)

Fix on both sides: server normalises to [] before writing the response, and the client defends with ?? []. Add an empty-state row ("This folder is empty") so a legitimately empty directory renders deliberately rather than as a blank table.

Dogfood finding (Nikola, 2026-07-30): opening an **empty** folder surfaces `Load failed: Cannot read properties of null (reading 'length')` instead of an empty-state. Cause: `GET /api/v1/files` marshals the driver's `items` slice, and an empty directory yields a nil slice → `"items": null` in JSON, so the client's `items.length` throws. (`storage.Driver.List` returns `nil, nil` in several drivers rather than an empty slice.) Fix on both sides: server normalises to `[]` before writing the response, and the client defends with `?? []`. Add an empty-state row ("This folder is empty") so a legitimately empty directory renders deliberately rather than as a blank table.
Author
Owner

Fixed in PR #72, released as v0.3.18, live on the .249 dogfood.

Verified on main: internal/api/api.go normalises a nil listing to []storage.FileInfo{} (root cause — an empty directory was marshalling as "items": null), the client defends with data.items ?? [], and an empty directory now renders the "This folder is empty" state instead of a blank table.

(Missed the auto-close because PR #72 named the issues in its title rather than a Closes #71 line.)

Fixed in PR #72, released as **v0.3.18**, live on the `.249` dogfood. Verified on main: `internal/api/api.go` normalises a nil listing to `[]storage.FileInfo{}` (root cause — an empty directory was marshalling as `"items": null`), the client defends with `data.items ?? []`, and an empty directory now renders the "This folder is empty" state instead of a blank table. (Missed the auto-close because PR #72 named the issues in its title rather than a `Closes #71` line.)
Cordy closed this issue 2026-07-30 03:21:26 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#71
No description provided.