github-api icon indicating copy to clipboard operation
github-api copied to clipboard

Exception on renaming label - `done()` should only be callable once for Setter or Updater

Open danhallin opened this issue 3 years ago • 1 comments

Describe the bug Throwing error when renaming label, the renaming does take place.

org.kohsuke.github.GHFileNotFoundException: https://api.github.com/repos/org/repo/labels/oldname {"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/issues#update-a-label"} at org.kohsuke.github.GitHubClient.interpretApiError(GitHubClient.java:540) at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:401) at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:355) at org.kohsuke.github.Requester.fetch(Requester.java:76) at org.kohsuke.github.AbstractBuilder.done(AbstractBuilder.java:109) at org.kohsuke.github.GHLabel$Setter.done(GHLabel.java:258)

To Reproduce Steps to reproduce the behavior:

GHLabel ghLabel = ghLabelWithOldName;
GHLabel.Setter setter = ghLabel.set();
setter.name(newname);
ghLabel = setter.done();

Expected behavior New label should be returned by .done()

Additional context Version 1.301 Likely caused from attempting to re-fetch label data with the old name which was just replaced and is no longer available.

danhallin avatar Jan 21 '22 08:01 danhallin

@danhallin The GHLabel.Setter automatically calls done after the call to setter.name(newname);.
This bug is still valid in that calling done() multiple times on the setter should result in a helpful exception message telling you this is not valid.

Try calling ghLabel.set().name(newname);.

bitwiseman avatar Jan 29 '22 06:01 bitwiseman