[Feature] Better HTTP request error logs
- [x] I'd be willing to implement this feature (contributing guide)
- [x] This feature is important to have in this repository; a contrib plugin wouldn't do
Describe the user story
A clear and concise description of what workflow is meant to be improved. Example: "As a developer, I often want to know what is the reason for the HTTP error, but I often face no logs but error code".
Describe the solution you'd like
Add 'verbose' flag to the command so it prints a better logging
Describe the drawbacks of your solution
I think it will be easier to cover specific & common cases like in 'yarn install / yarn npm publish' since most of the errors are faced when dealing with private registries
Describe alternatives you've considered
why not make it a plugin? I think it crucial to enable better debugging within yarn tool itself
We already print most of the info we have (in particular the status code and the URL that failed); what else would you expect to see?
The response body. I am getting 403 from jFrog in their body they say it's an existing package, but all I am seeing is Forbidden.
When adding console.log myself to the yarn.cjs
response body {
errors: [
{
status: 403,
message: "Not enough permissions to delete/overwrite artifact 'npm-dev-local:@scope/package' (user: '[email protected]' needs DELETE permission)."
}
]
}
VS yarn logs
➤ YN0035: The remote server failed to provide the requested resource
➤ YN0035: Response Code: 403 (Forbidden)
➤ YN0035: Request Method: PUT
➤ YN0035: Request URL: https://company.jfrog.io/artifactory/artifactory-name/package-name
➤ YN0000: Failed with errors in 0s 106ms
This log could be very useful and save a lot of time :) I think the fix should be here
@arcanis I have created a fix branch on my machine (pulled yarn and setup a development env). How can I push this code to a new branch and offer PR? (getting permission issues).
Before the PR:

After my PR:

Motivation: I am working in a startup where we use jFrog as our artifactory.
- jFrog returns 403 for trying to push existing package (I would assume it would return 409), since there is insufficient permissions to remove the old package.
- jFrog returns 409 for trying to push a folder. (another issue, I am gonna try to debug)
I couldn't find these reasons / debug from yarn side or from jFrog side. I ended up having a yarn.cjs and inserting my own console logs there to see the response.body.
Conclusion it would be better to print the response body. Since we cant rely on it's structure (for example { errors: [...] }) I think it would be the best to show a raw body.
This could save me a lot of days and I believe can be helpful to more people.
While I understand the issue, it doesn't look super good and it takes a lot of vertical space. Rather than displaying the body, I'd prefer to store it in a temporary file and print its path (which is the same thing we do for build scripts).
@arcanis Sounds to me like a great idea, I will try to find a reference and implement. Can I get your help pushing a branch? Thanks
Can I get your help pushing a branch?
See https://docs.github.com/en/get-started/quickstart/contributing-to-projects
Thank you, a bit out of context :) I will go back to it and try in a few days
+1
It would be really useful to know that Invalid authentication (as an anonymous user) actually means (in this case) 401 "Access Denied: The Personal Access Token used has expired. - Azure DevOps Server" without having to do 30 minutes of step-through debugging of minified js.