fix: nil slice -> empty slice in list API responses

Backend:
- ListStorageJobs, ListSambaShares, ListNFSExports, ListUsers,
  ListDirty, ListApplyLog, ListWatchedMounts: initialize with
  make([]T, 0) instead of var x []T to avoid JSON null on empty.
  Fixes "Cannot read properties of null" crash on /storage.

Frontend:
- Storage.tsx: defensive setJobs(res.jobs ?? []) to guard against
  API returning null.

Tests:
- Add TestListStorageJobsEmptyReturnsSlice.

Version: 0.7.1
This commit is contained in:
2026-07-06 23:31:03 -04:00
parent 27a52d2986
commit d3d59b4e45
9 changed files with 37 additions and 9 deletions
+1 -1
View File
@@ -170,7 +170,7 @@ func (d *DB) ListStorageJobs(limit int) ([]StorageJob, error) {
}
defer rows.Close()
var jobs []StorageJob
jobs := make([]StorageJob, 0)
for rows.Next() {
j, err := scanStorageJob(rows)
if err != nil {