Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 358924 - [github] FieldError is missing a message field
Summary: [github] FieldError is missing a message field
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Thomas Hallgren CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-26 12:04 EDT by Thomas Hallgren CLA
Modified: 2011-09-27 19:38 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Hallgren CLA 2011-09-26 12:04:26 EDT
I'm trying to provide some meaningful feedback to the end user when he makes attempts to create a repository using the GitHub v3 API. It's a bit hard to make sense of the exception that I get when a repository by the given name already exists. The JSon output from GitHub looks like this:

{"message":"Validation Failed","errors":[{"field":"name","message":"name is already taken","code":"custom","resource":"Repository"}]}

which seems OK. But the RequestException that I get back will only print:

"Validation Failed (422): Error with 'name' field in Repository resource"

In the RequestException there's a RequestError with a list containing one FieldError. The field error lacks a message field and hence contains only:

{"field":"name","code":"custom","resource":"Repository"}

I think the problem is twofold. First of all, the 'message' field should be added to the FieldError class, second, an issue should be reported against the Git v3 API that the code = "custom" is inconsistent. According to the documentation [1], it should really be "already_exists"

[1] http://developer.github.com/v3/#client-errors
Comment 1 Thomas Hallgren CLA 2011-09-26 12:09:43 EDT
Patch added: http://egit.eclipse.org/r/#change,4292
Comment 2 Kevin Sawicki CLA 2011-09-26 12:14:11 EDT
Have you tried calling RequestException.getError().getMessage()? I think that provides the message you are looking for.
Comment 3 Thomas Hallgren CLA 2011-09-26 12:18:41 EDT
No, it just prints "Validation Failed"

A sent a note about the inconsistent code to github support.
Comment 4 Kevin Sawicki CLA 2011-09-26 12:20:47 EDT
Yes, you are right, the nested message is missing from the field error.
Comment 5 Thomas Hallgren CLA 2011-09-26 12:26:59 EDT
I meant to write "inconsistent code attribute". The actual code is consistent enough :-)
Comment 6 Kevin Sawicki CLA 2011-09-27 19:38:07 EDT
Merged into master as commit 706fa65b8ee1f2d1b14863af21ced8dd9fe9f582