api/checkpoint: Don't return null if no checkpoints

This fixes a bug where no checkpoints would produce a `null` response
instead of an empty array:

```
$ docker run -d --name foo nginx:alpine
17fbeff7185733f101c38cb8208359dd0ef141116a1345da2d3c3f58c11f3e14

$ curl --unix-socket /var/run/docker.sock http://local/containers/foo/checkpoints
null
```

With this patch, this becomes:
```
$ curl --unix-socket /var/run/docker.sock http://local/containers/foo/checkpoints
[]
```

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 646e068cf1)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2025-09-26 16:43:27 +02:00
parent 73f8d82c4b
commit fd10938136

View File

@@ -38,6 +38,9 @@ func (cr *checkpointRouter) getContainerCheckpoints(ctx context.Context, w http.
if err != nil {
return err
}
if checkpoints == nil {
checkpoints = []checkpoint.Summary{}
}
return httputils.WriteJSON(w, http.StatusOK, checkpoints)
}