Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    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..)

    Scheduled Pinned Locked Moved Support
    4 Posts 2 Posters 5 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R Offline
      robert_3065
      last edited by

      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?

      atrippA 1 Reply Last reply Reply Quote 0
      • atrippA Offline
        atripp inedo-engineer @robert_3065
        last edited by

        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 to http://OURSERVER/npm/npm_internal/, which is supposed to be in a base64-formatted api:apikey or 'user:password format.

        Here's some more information about it:
        https://docs.inedo.com/docs/proget-feeds-npm#npm-token-authentication

        Npm auth isn't so intuitive unfortunately :/

        Alana

        1 Reply Last reply Reply Quote 0
        • R Offline
          robert_3065
          last edited by

          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

          atrippA 1 Reply Last reply Reply Quote 0
          • atrippA Offline
            atripp inedo-engineer @robert_3065
            last edited by

            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

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post
            Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation