fix: empty changeset must serialize as [] not null (white-screen after snapshot)
toChangesetResponse initialises updates/prunes/readOnly so a zone matching its template exactly (e.g. right after 'create template from zone') marshals arrays, not null. DiffView/DomainDiffPage also normalise null defensively. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BwxdSt4reTm7Dj1oxRvpP3
This commit is contained in:
+9
-1
@@ -72,7 +72,15 @@ func toRecordView(d diff.RecordDiff) recordView {
|
||||
}
|
||||
|
||||
func toChangesetResponse(cs diff.Changeset) changesetResponse {
|
||||
resp := changesetResponse{}
|
||||
// Initialise the slices so an empty changeset (e.g. a zone that exactly
|
||||
// matches its template right after a snapshot) marshals to [] rather than
|
||||
// null — a nil slice becomes JSON null, which crashes clients that call
|
||||
// .length/.map on the field.
|
||||
resp := changesetResponse{
|
||||
Updates: []recordView{},
|
||||
Prunes: []recordView{},
|
||||
ReadOnly: []recordView{},
|
||||
}
|
||||
for _, d := range cs.Updates() {
|
||||
resp.Updates = append(resp.Updates, toRecordView(d))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user