base64 Encoding Pitfall

A picture is worth 1000 words, but let me start with the context. We are updating some config files in our deployment and we need base64 encode our user:pass as the token. My team isn’t allowed to do our own updates to production; we’re required to schedule releases with DevOps and provide them with a RunBook of step-by-step instructions. Here’s what I wrote, and note that I’m writing this piece because there was a process failure:

Image of python instructions to base64 encode a string.

My intern was able to follow these instructions to curl the API endpoint, so I figured all would be fine when seasoned professionals put their hands on the instructions. I suppose “figured” in the last sentence is a synonym for “assumed”….

DevOps notified us that they completed the process. I identify that we have a failure connecting to the service that the token is supposed to grant access to. When we asked about the JSON that was added to the config file, we’re told DevOps copied the return value from the encoding:

Image: screenshot of the response from DevOps that they did not copy the return value as directed.

By which they meant they copied all of “b’SooperSekritToekin'” from above.


As the author of the doc, where could I have been clearer? Would color have helped? I probably should have added a step (despite always getting pushback for doing so) that would have eliminated the need for the user to selectively copy something. For future reference, this is what the base64 encoding instructions will look like:

$ python3
>>> import base64
>>> t = base64.b64encode(bytes('username:password', 'ascii'))  n.b. do not forget the colon between
>>> print(t.decode()) 
# SooperSekritToekin  <-- copy this
Advertisements
base64 Encoding Pitfall