Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the TypeError exception in the images.prune method #412

Merged
merged 1 commit into from
Aug 1, 2024
Merged

Fix the TypeError exception in the images.prune method #412

merged 1 commit into from
Aug 1, 2024

Conversation

milanbalazs
Copy link
Contributor

If the prune doesn't remove images, the API returns null (with 200 status code) and it's interpreted as None (NoneType) so the for loop throws the following exception:

"TypeError: 'NoneType' object is not iterable".

My fix handles the above described case and the client.images.prune() returns a valid Dict with zero values, which is correct because the Podman didn't remove anything:

{
    "ImagesDeleted": [],
    "SpaceReclaimed": 0,
}

It's fix for:

@inknos inknos self-requested a review August 1, 2024 14:30
@inknos
Copy link
Contributor

inknos commented Aug 1, 2024

Thanks. I got some errors after pulling and local testing. Will get back as soon as I verify what's happening :)

If the prune doesn't remove images,
the API returns "null" (with 200) and it's interpreted as
None (NoneType) so the for loop throws:
"TypeError: 'NoneType' object is not iterable".

My fix handles the above described case and the
client.images.prune() returns a valid Dict with zero
values, which is correct because the Podman didn't
remove anything

Signed-off-by: Milan Balazs <[email protected]>
@milanbalazs
Copy link
Contributor Author

Thanks. I got some errors after pulling and local testing. Will get back as soon as I verify what's happening :)

Hi @inknos,

Thanks for your feedback! I have just fixed the error (Squashed the commits)!

@rhatdan
Copy link
Member

rhatdan commented Aug 1, 2024

LGTM
@inknos @jwhonce @umohnani8 PTAL

@inknos
Copy link
Contributor

inknos commented Aug 1, 2024

/lgtm now. Thanks @milanbalazs

@inknos
Copy link
Contributor

inknos commented Aug 1, 2024

/lgtm

@rhatdan
Copy link
Member

rhatdan commented Aug 1, 2024

/approve

Copy link
Contributor

openshift-ci bot commented Aug 1, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: inknos, milanbalazs, rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Aug 1, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit c5bde04 into containers:main Aug 1, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants