You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here, the route is missing /generate-notes at the end, as per REST API docs.
What's funny is that all parameters to the .../releases/generate-notes entry point are also valid parameters to the .../releases entry point, thus the HTTP request returns 200 OK.
Furthermore, the .../releases response contains, among others, all fields of the .../releases/generate-notes response and is thus successfully deserialized to GeneratedReleaseNotes.
The end result is that the method succeeds, even if the outcome is far from what one may expect: a new release is created and published, triggering validation errors in a later call to either ReleasesClient.Create or ReleasesClient.Edit with the same tag name.
By the way, the route is wrong in unit tests, too:
This route is missing /generate-notes at the end too, plus it doesn't even match method parameters, as it has /repos/{owner}/{repo} instead of /repositories/{id}.
I haven't experimented with this one, but I strongly suspect it throws.
The unit test here tests the right route though (minus /generate-notes):
How can the test pass? It may be related to how method parameters are mapped to ManualRoute attributes, but I'm just guessing here.
EDIT: Turns out ManualRoute attributes are actually not used to generate URLs: static methods of class ApiUrls are called instead. GenerateReleaseNotes methods call ApiUrls.Releases methods, which construct URLs suitable for listing releases, not for generating release notes. What's missing are two ApiUrls.ReleasesGenerateNotes methods (one for owner / repo, the other for repository ID) that return URLs with /generate-notes appended.
Please forgive me if I came out as blunt: it is not in my intentions to offend anyone. I think @Cristaling did a great job with the GenerateReleaseNotes implementation, by the way. I was just trying to be concise, fighting against my over-verbose Italian nature, 😄 and I realized later I might have erred on the other side.
How about I open a PR for this?
The text was updated successfully, but these errors were encountered:
rdeago
changed the title
ReleasesClient.GenerateReleaseNotes calls the wrong URL
ReleasesClient.GenerateReleaseNotes uses the wrong URL and HTTP method
Oct 7, 2022
Both overloads of
ReleasesClient.GenerateReleaseNotes
have incorrect routes.EDIT: They also use the GET method instead of POST.
octokit.net/Octokit/Clients/ReleasesClient.cs
Lines 33 to 34 in 8624d90
Here, the route is missing
/generate-notes
at the end, as per REST API docs.What's funny is that all parameters to the
.../releases/generate-notes
entry point are also valid parameters to the.../releases
entry point, thus the HTTP request returns200 OK
.Furthermore, the
.../releases
response contains, among others, all fields of the.../releases/generate-notes
response and is thus successfully deserialized toGeneratedReleaseNotes
.The end result is that the method succeeds, even if the outcome is far from what one may expect: a new release is created and published, triggering validation errors in a later call to either
ReleasesClient.Create
orReleasesClient.Edit
with the same tag name.By the way, the route is wrong in unit tests, too:
octokit.net/Octokit.Tests/Clients/ReleasesClientTests.cs
Lines 34 to 36 in 8624d90
octokit.net/Octokit/Clients/ReleasesClient.cs
Lines 53 to 54 in 8624d90
This route is missing
/generate-notes
at the end too, plus it doesn't even match method parameters, as it has/repos/{owner}/{repo}
instead of/repositories/{id}
.I haven't experimented with this one, but I strongly suspect it throws.
The unit test here tests the right route though (minus
/generate-notes
):octokit.net/Octokit.Tests/Clients/ReleasesClientTests.cs
Lines 48 to 50 in 8624d90
How can the test pass? It may be related to how method parameters are mapped to
ManualRoute
attributes, but I'm just guessing here.EDIT: Turns out
ManualRoute
attributes are actually not used to generate URLs: static methods of classApiUrls
are called instead.GenerateReleaseNotes
methods callApiUrls.Releases
methods, which construct URLs suitable for listing releases, not for generating release notes. What's missing are twoApiUrls.ReleasesGenerateNotes
methods (one for owner / repo, the other for repository ID) that return URLs with/generate-notes
appended.Please forgive me if I came out as blunt: it is not in my intentions to offend anyone. I think @Cristaling did a great job with the
GenerateReleaseNotes
implementation, by the way. I was just trying to be concise, fighting against my over-verbose Italian nature, 😄 and I realized later I might have erred on the other side.How about I open a PR for this?
The text was updated successfully, but these errors were encountered: