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: make Client.Pull properly handle API errors #452

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

benhoyt
Copy link
Contributor

@benhoyt benhoyt commented Jul 17, 2024

Currently the Client.Pull method is immediately checking the content type for multipart, but we should also check for a regular API error. This PR fixes that.

Before (in case of permission denied error):

$ pebble pull /etc/hosts hosts
error: expected a multipart response, got "application/json"

After:

$ pebble pull /etc/hosts hosts
error: access denied (try with sudo)

Fixes #413

@benhoyt benhoyt requested a review from anpep July 17, 2024 04:49
Copy link
Collaborator

@anpep anpep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thanks!

@benhoyt benhoyt merged commit 02e5d2d into canonical:master Jul 17, 2024
16 checks passed
@benhoyt benhoyt deleted the pull-error branch July 17, 2024 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"pebble pull" gives wrong error in case of access denied
2 participants