HTTP error 409 (Conflict) occurs during getting the patch for a change

835 views
Skip to first unread message

Mikalai Barysau

unread,
Jul 28, 2016, 8:15:56 AM7/28/16
to Repo and Gerrit Discussion
Hello, everyone!

I am writing an application, which uses Gerrit REST API. In particular it uses Get Patch (https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-patch) request, which returns a complete diff against the base revision.
During my experiments with the application it turned out, that for some changes this request reseives 409 HTTP error. I haven't found a description of such situation in the official documentation. I also haven't found any discussion regarding this problem on google.
After short analysis I noticed, that all changes, that received 409, were merges with conflicts, so the first patch set has multiple parents and o Gerrit web app this changes doesn't have a 'Base' revision. Instead of it they have 'Auto Merge', which contains source files with git markers for resolving conflicts. It makes sense, since final patch is supposed to be applied to the base revision, But since there are multiple base revisions, you have to merge it first. 

It means, that for some changes Get Patch operation actually fails and the application may switch to unexpected state.
I would like to know, if there is a solution for such a problem?

For example, if you request a diff (https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-diff) you can also specify the base revision for the diff (for example you want diff for specific file between patch set 1 and 9). The only problem here, is that in patch you have all files all together. In case of diff, you have to specify filename each time.

Dave Borowitz

unread,
Jul 28, 2016, 9:17:29 AM7/28/16
to Mikalai Barysau, Repo and Gerrit Discussion
For 409 responses there is a human-readable error message in the response body, so that's the first place to look when you encounter this.

In the particular case of Get Patch, it returns this error if there is not exactly 1 parent. I think that is just because nobody felt like implementing it.

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mikalai Barysau

unread,
Jul 28, 2016, 9:48:52 AM7/28/16
to Repo and Gerrit Discussion, nick.b...@gmail.com
Yeah, you're right. The response body contains message ''Revision has more than 1 parent."
Seems like Get Patch is just not applicable for such cases.

Thanks for your help!

Dave Borowitz

unread,
Jul 28, 2016, 10:05:31 AM7/28/16
to Mikalai Barysau, Repo and Gerrit Discussion
https://gerrit-review.googlesource.com/80562 to document that error responses are human readable. (Doesn't actually help the discoverability of this information if you didn't know to look there though.)
Reply all
Reply to author
Forward
0 new messages