vv9k / podman-api-rs

Rust interface to Podman (libpod).
MIT License
84 stars 12 forks source link

ListContainer deserialization error: podman returns null for Size #129

Closed Mortal42 closed 2 years ago

Mortal42 commented 2 years ago

Podman swagger doesn't specify that "Size" can be null, but returns it. Example output from curl: [{"AutoRemove":false,"Command":["bash"],"Created":"2022-08-10T18:57:42.243852139-07:00","CreatedAt":"","Exited":false,"ExitedAt":-62135596800,"ExitCode":0,"Id":"ed289912f4fa9c2bdf1599d80e614397b05d947c1c7d0a55d6f261d31e512ddf","Image":"docker.io/library/ubuntu:latest","ImageID":"df5de72bdb3b711aba4eca685b1f42c722cc8a1837ed3fbd548a9282af2d836d","IsInfra":false,"Labels":null,"Mounts":[],"Names":["bash"],"Namespaces":{},"Networks":["podman"],"Pid":0,"Pod":"","PodName":"","Ports":null,"Size":null,"StartedAt":-62135596800,"State":"created","Status":""}]

Example rust code:

    let api = Podman::unix("/var/run/podman/podman.sock");

    let data = api.containers().list(
        &ContainerListOpts::builder()
            .all(true)
            .build(),
        ).await?;

Works if .size(true) used, fails with Error: invalid type: null, expected struct ContainerSize at line 1 column 497 otherwise.

vv9k commented 2 years ago

There was a slight problem with generated models in 0.4.0 that made most struct fields required (non-optional) but it should be resolved as of c01d4b5db1302ca7163876debad180b9ec1954b7 . There is a new version 0.5.0 published that should contain those changes.