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

Add nice error message #11859

Merged
merged 1 commit into from
Mar 30, 2015
Merged

Add nice error message #11859

merged 1 commit into from
Mar 30, 2015

Conversation

HuKeping
Copy link
Contributor

Fixes #9315
Fixes #10983
Generally, when using Remote API to push images there needs a http Header
X-Registry-Auth.
For compatibility if there was no authConfig header, everything will be
okay if a proper JSON-http-body was applied.

But when both X-Registry-Auth Header and the Body are missing, due to
the function of decode JSON, it will return an EOF error which was not
very clear to user.

So I think we can make the respone error be more nice.

Signed-off-by: Hu Keping hukeping@huawei.com

@@ -662,7 +662,7 @@ func postImagesPush(eng *engine.Engine, version version.Version, w http.Response
} else {
// the old format is supported for compatibility if there was no authConfig header
if err := json.NewDecoder(r.Body).Decode(authConfig); err != nil {
return err
return fmt.Errorf("Bad parameters and missing X-Registry-Auth")
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the idea of a nice error message, but can we include the original error message text too since it might include a clue as to what was wrong with the data that was being decoded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it will be more clear.

@HuKeping
Copy link
Contributor Author

updated

Generally, when using Remote API to push images there needs a http Header
X-Registry-Auth.
For compatibility if there was no authConfig header, everything will be
okay if a proper JSON-http-body was applied.

But when both X-Registry-Auth Header and the Body are missing, due to
the function of decode JSON, it will return an EOF error which was not
very clear to user.

So I think we can make the respone error be more nice.

Signed-off-by: Hu Keping <hukeping@huawei.com>
@crosbymichael
Copy link
Contributor

LGTM

crosbymichael added a commit that referenced this pull request Mar 30, 2015
@crosbymichael crosbymichael merged commit fe9f322 into moby:master Mar 30, 2015
@HuKeping HuKeping deleted the eof branch April 3, 2015 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants