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>
This commit is contained in:
Paweł Gronowski
2025-09-26 16:43:27 +02:00
parent 2670796a01
commit 646e068cf1

View File

@@ -39,6 +39,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)
}