Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.
If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!
500 upon GET-ing package via node/yarn (..not a valid Base-64 string..)
-
One of our build agents consistently receives a 500 error while obtaining node packages:
An error occurred processing a GET request to http://OURSERVERNAME/npm/npm/@angular/material/-/material-12.2.13.tgz: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
Stack trace:
System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. at System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength) at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength) at System.Convert.FromBase64String(String s) at Inedo.ProGet.WebApplication.Security.WebApiContext.CreateFromBasicAuth(HttpContext context) at Inedo.ProGet.WebApplication.FeedEndpoints.Npm.NpmHandler.CreateWebApiContext(HttpContext context, NpmFeed feed, String relativeUrl) at Inedo.ProGet.WebApplication.FeedEndpoints.FeedHandler`1.Inedo.ProGet.WebApplication.FeedEndpoints.IFeedHandler.ProcessRequestAsync(HttpContext context, Feed feed, String relativeUrl) at Inedo.ProGet.WebApplication.FeedEndpoints.FeedEndpointHandler.FeedRequestHandler.<ProcessRequestAsync>d__8.MoveNext()
The build agents (also the ones that do work) are reported
yarn/1.22.0+npm/?+node/v12.14.1+win32+x64
We though this may be a yarn-spoecific isue so we upgrade yarn (from 122.0 to 1.22.17) but no luck:
yarn/1.22.17+npm/?+node/v12.14.1+win32+x64
The node version is the same between machines
As the stack trace indicated this may be related to authentication, we also queried if there was anything wrong with our authentication, by running:
npm whoami --registry=http://OURSERVER/npm/npm_internal/
Which returned the name of our authenticated user.
Any suggestion on what we could log to have more clarity?
-
Hi @robert_3065,
Based on this, I think the
_auth
token in your.npmrc
file isn't correct. That is the token that's sent tohttp://OURSERVER/npm/npm_internal/
, which is supposed to be in abase64
-formattedapi:apikey
or'user:password
format.Here's some more information about it:
https://docs.inedo.com/docs/proget-feeds-npm#npm-token-authenticationNpm auth isn't so intuitive unfortunately :/
Alana
-
Hi @atripp ,
Thanks for responding so quickly!
You are right, this appears to be an authentication issue with the NPM config. I think either my token was not prefixed with
api:
before encoding, and in a later attempt I mistakenly prefixed the token after encoding.I still think the Proget error message could be a little bit more helpful (more eloquent bad request message while validating the input or so) instead of just crashing with a 500.
The particular feed I was accessing allows anonymous usage, so discarding the
.npmrc
file helped my build.
I'm now starting with a clean.npmrc
file, and know where to look when I need to authenticate (for instance fore publishing a package)Regards,
Robert Sirre
-
Hi @robert_3065 ,
Glad it's working!
Good point about the error message; it's in a kind of general place, so I just replaced that unhelpful base64 decoding message with this (via PG-2069):
string userPassString; try { userPassString = context.Request.ContentEncoding.GetString(Convert.FromBase64String(authHeader.Substring("Basic ".Length))); } catch (FormatException) { throw new HttpException(400, "Invalid Basic credential (expected base64 of username:password)"); }
Not the perfect solution, but better than now!
Cheers,
Alana