Skip to content

Fix bug with session id name#414

Merged
molly-moen merged 3 commits into
mainfrom
molly-session-id-fix
Jun 12, 2026
Merged

Fix bug with session id name#414
molly-moen merged 3 commits into
mainfrom
molly-session-id-fix

Conversation

@molly-moen

@molly-moen molly-moen commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

I noticed today that Javabuilder was frequently failing to connect, with the websocket request returning a 502. I (with help from Claude) tracked the error down to StartSessionsAndRelayMessagesFunction, which was logging
"errorMessage": "The name of a FIFO queue can only include alphanumeric characters, hyphens, or underscores, must end with .fifo suffix and be 1 to 80 in length.",. This error pointed to how we were naming our SQS queues. This hasn't changed on our end, but we make an assumption that the websocket connection ids we use to generate the queue names end with a single =. In the case of the failures I found, the ids ended with 2 equals signs. The equals signs aren't valid in FIFO queue names, and therefore we were failing to make the queues.

It seems like this is a recent change in how websocket connection ids are generated. I've been using Javabuilder a lot lately and only noticed this happening frequently today. The last week of logs confirm this:
Screenshot 2026-06-12 at 10 47 09 AM

To fix this, instead of only stripping the last = from the connection id, we instead will strip all =.

Testing

I tried to deploy a dev javabuilder instance, but the permissions are broken right now. This change seems pretty safe and I added unit tests for it, so I feel ok about pushing it forward without full testing.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes generation of the “session id” (used as part of the per-connection SQS FIFO queue name) by stripping all trailing Base64 padding characters (=) from the API Gateway connectionId, preventing invalid SQS queue names when the ID ends with multiple =.

Changes:

  • Extracted get_session_id(event) into a dedicated SessionIdHelper module and updated logic to remove one-or-more trailing = characters.
  • Updated api_gateway_proxy_function.rb to use the new helper module instead of an inline implementation.
  • Added Minitest coverage validating behavior for single padding, multiple padding, and no padding cases.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
api-gateway-routes/test/session_id_helper_test.rb Adds unit tests ensuring session IDs strip trailing = padding correctly.
api-gateway-routes/session_id_helper.rb Introduces shared helper to derive a safe session ID for SQS queue naming.
api-gateway-routes/api_gateway_proxy_function.rb Switches to the new helper and removes the previous inline get_session_id implementation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@molly-moen molly-moen marked this pull request as ready for review June 12, 2026 20:14
@molly-moen molly-moen requested a review from a team June 12, 2026 20:14

@bencodeorg bencodeorg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa, nice find! So AWS generates the connectionId? And we think that changed somehow?

@molly-moen

Copy link
Copy Markdown
Contributor Author

So AWS generates the connectionId? And we think that changed somehow?

Yep!

@molly-moen molly-moen merged commit 253d0df into main Jun 12, 2026
1 check passed
@molly-moen molly-moen deleted the molly-session-id-fix branch June 12, 2026 20:55
# The connection ID is base64-encoded, so it can end with one or more '='
# padding characters. We remove all of them here.
def get_session_id(event)
event["requestContext"]["connectionId"].sub(/=+$/, "")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to consider 1-way hashing the connection id with something like sha256 to ensure alphanumeric to future proof this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants