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:
@@ -114,7 +114,7 @@ func (d *DB) ListDirty() ([]DirtyModule, error) {
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var modules []DirtyModule
|
||||
modules := make([]DirtyModule, 0)
|
||||
for rows.Next() {
|
||||
var module DirtyModule
|
||||
var markedAt string
|
||||
@@ -158,7 +158,7 @@ func (d *DB) ListApplyLog(limit int) ([]ApplyLogEntry, error) {
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var entries []ApplyLogEntry
|
||||
entries := make([]ApplyLogEntry, 0)
|
||||
for rows.Next() {
|
||||
var entry ApplyLogEntry
|
||||
var success int
|
||||
@@ -182,7 +182,7 @@ func (d *DB) ListSambaShares() ([]SambaShare, error) {
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var shares []SambaShare
|
||||
shares := make([]SambaShare, 0)
|
||||
for rows.Next() {
|
||||
share, err := scanSambaShare(rows)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user