-
Notifications
You must be signed in to change notification settings - Fork 65
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
Documentation differs from Implementation for /packageManifests/{id} return codes (204 or 404) #170
Comments
404 is the correct HTTP return code. We should look to improve the client experience by either parsing the JSON returned by the REST source and returning that to the client, or some other more user-friendly message like "Package not found". |
I'm back because it turns out returning 404 doesn't just result in ugly client-side error messages, it also breaks functionality. The following has been tested with my own REST source implementation and winget CLI v1.4.3531. When performing a winget query like:
against a REST source, we see the following requests logged by the server:
This results in the following output from winget-CLI:
Unfortunately, the winget-CLI automatically falls back to the official
So the PowerShell cmdlet just outright fails and doesn't return any result (at least that part is working). However, we can see that when winget-CLI does auto-fallback to the official winget source it does find a match and the REST server request logs show that while the initial query from the client to If I change the REST server to return 204 instead of 404 when a With PowerShell:
With the old-school CLI:
Just for completeness, the REST server request logs are now:
So it appears that returning 404 from |
It looks like @palenshus had already noticed this as well: #107 So basically, the REST implementation in both the winget-client and in the reference-restsource is wrong, it should be a 404, but because the client doesn't handle and doesn't expect 404s correctly and because the reference implementation doesn't use 404s correctly either, one is forced to implement the entirely undocumented 204 response 🤦 |
Yes, based on https://learn.microsoft.com/azure/architecture/best-practices/api-design#get-methods we should return 404, and the client should handle it correctly. We may need to adjust the reference implementation as well if it's handing out 204. |
Related to: |
I tend to agree with @denelon. Reading the api-design methods for get reference above:
If we are not finding the resource - 404 is correct (all the references above are non-search based) and we need to correct that in the reference. The one exception would be on manifestSearch - 204 would make sense if we successfully perform a search that returns no results - which appears to be functioning as intended. The second part of your statement is also true - we need to do some updates on the client to parse/process 404 errors better. |
Brief description of your issue
Hi,
according to both the 1.1.0 and 1.4.0 REST API schema, the
/packageManifests/{PackageIdentifier}
route is only supposed to return200
,404
or another error:https://github.com/microsoft/winget-cli-restsource/blob/main/documentation/WinGet-1.1.0.yaml#L506-L522
https://github.com/microsoft/winget-cli-restsource/blob/main/documentation/WinGet-1.4.0.yaml#L506-L522
However, the reference implementation also explicitly tests for the undocumented
204
here:https://github.com/microsoft/winget-cli-restsource/blob/main/src/WinGet.RestSource/Helpers/RestSourceTriggerFunctions.cs#L63
which raises the question - should a REST source return
404
like the schema suggests when a packageIdentifier is not found or should it return204
? I have noticed in testing that winget responds with a red error message when it gets a404
(which I guess is fine / maybe intended?) but responds with a much more calm "no results found" message when it gets a204
- so the client seems to handle the undocumented 204 more gracefully, further hinting that that's maybe the intended return code and the schema docs are wrong?Thanks!
The text was updated successfully, but these errors were encountered: