Skip to content

fix(bbb-graphql-middleware): End the connection handler on a rejected connection init - #26617

Merged
antobinary merged 3 commits into
bigbluebutton:v4.0.x-developfrom
imdt-claudiop:pr/connection-init-rejection-return
Nov 20, 2026
Merged

antobinary merged 3 commits into
bigbluebutton:v4.0.x-developfrom
imdt-claudiop:pr/connection-init-rejection-return

Conversation

@imdt-claudiop

Copy link
Copy Markdown
Contributor

What does this PR do?

When the middleware rejected a connection at its init, the connection handler did not stop there. The handler now returns right after closing a rejected connection. Nothing changes for accepted connections.

Closes Issue(s)

None.

Motivation

connectionInitHandler rejects a connection whose init is missing a required header or fails the checks at connection time. ConnectionHandler then closed the connection with the error and went on as if it had been accepted: it counted it in ws_connection_accepted, registered it as a user connection and started the Hasura and gql-actions clients for it.

How to test

In a clean checkout (for example a golang:1.27-bookworm container with only bbb-graphql-middleware, without /usr/share/bbb-graphql-middleware and without /etc/bigbluebutton), run in bbb-graphql-middleware:

go build ./... && go vet ./... && go test -race -count=2 ./...

The new test in internal/websrv/connectionInitRejection_test.go sends an init without a required header and checks that the handler ends without registering the connection, and that the client was rejected at its init (param_missing) and not before it.

More

Depends on #26615: this branch is built on it, because its test runs in internal/websrv, whose tests need config/testconfig to run without an installed configuration. Until #26615 is merged, this PR also shows its two commits; the change here is the last commit. Docs not affected.

imdt-claudiop and others added 3 commits November 18, 2026 21:51
go vet reports printf-style calls whose format does not match its
arguments: Debug and Errorf used as if the other were the f variant, an
error built from a non-constant format string, and a context whose
cancel function was discarded in the writer's query rate limiter wait.
Use the matching logrus call, errors.New for the plain message, and
cancel the rate limiter context as soon as the wait returns.

Co-authored-by: Tiago Jacobs <[email protected]>
Some packages read the configuration when they are initialized, from
/usr/share/bbb-graphql-middleware/config.yml and an override in
/etc/bigbluebutton, so a test binary of such a package failed on a
machine without the middleware installed: go test ./... already failed
in internal/websrv. The config/testconfig package points the
configuration at the repository's config/config.yml and at an override
path that does not exist; a package whose tests load the configuration
imports it from a test file. Go initializes it right after config,
before any internal package.

Co-authored-by: Tiago Jacobs <[email protected]>
When connectionInitHandler rejected a connection, ConnectionHandler
closed it with the error and then went on as if it had been accepted:
it counted it in ws_connection_accepted, registered it as a user
connection and started the Hasura and gql-actions clients for it.
Return right after closing a rejected connection.

The test sends an init without a session token and checks that the
handler ends without registering the connection, and that the browser
was rejected at the init (param_missing) and not before it.

Co-authored-by: Tiago Jacobs <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The PR adds test configuration for the middleware and makes the connection handler return after rejecting a connection initialization. It adds a WebSocket test for that rejection. It also changes error construction and log formatting in several clients, and cancels a rate-limiter timeout context after the wait returns.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: gustavotrott, paultrudel

Merge Risk: Minimal · up to 5164c

This change stops the handler from treating a rejected connection as accepted, and the added test covers that case. The remaining changes are small error and log corrections. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description check Passed The description states the problem, the fix, the motivation, test steps, and a dependency on #26615. It matches the changeset: the connection handler return, the new test, and the testconfig setup. It…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title names a fix that matches the main change. The PR makes ConnectionHandler return right after connectionInitHandler rejects a connection, so the handler stops before it registers the connectio…
Full details: Description check

Explanation

The description states the problem, the fix, the motivation, test steps, and a dependency on #26615. It matches the changeset: the connection handler return, the new test, and the testconfig setup. It is not off-topic.

Full details: Title check

Explanation

The title names a fix that matches the main change. The PR makes ConnectionHandler return right after connectionInitHandler rejects a connection, so the handler stops before it registers the connection or starts the Hasura and gql-actions clients. The title uses the Conventional Commits prefix and gives the component and the specific behavior. It is 85 characters, a little over the usual length, but it stays clear.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fecba731-e893-46bd-b7d9-17e47a67af26
Commits

Reviewing files that changed from the base of the PR and between 3098b16 and 5164c40.

Files selected for processing: 9

  • bbb-graphql-middleware/config/testconfig/testconfig.go
  • bbb-graphql-middleware/internal/akka_apps/client.go
  • bbb-graphql-middleware/internal/bbb_web/client.go
  • bbb-graphql-middleware/internal/gql_actions/client.go
  • bbb-graphql-middleware/internal/hasura/conn/reader/reader.go
  • bbb-graphql-middleware/internal/hasura/conn/writer/writer.go
  • bbb-graphql-middleware/internal/websrv/connectionInitRejection_test.go
  • bbb-graphql-middleware/internal/websrv/connhandler.go
  • bbb-graphql-middleware/internal/websrv/testconfig_test.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@github-actions

Copy link
Copy Markdown

✅ Automated tests have passed!

@antobinary antobinary added this to the Release 4.0 milestone Nov 19, 2026
@antobinary antobinary changed the title End the connection handler on a rejected connection init fix(bbb-graphql-middleware): End the connection handler on a rejected connection init Nov 19, 2026

@TiagoJacobs TiagoJacobs left a comment

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.

Reviewed and tested on a 4.0 server built from source at v4.0.x-develop commit 3098b16087, with only the middleware swapped between that commit and this branch.

A real case that reaches it: a client that is offline when its meeting ends. When the network comes back, bbb-web no longer authorizes that session, the client shows its error screen and retries about every 10 seconds. In 180 seconds that produced 16 websocket connections, all rejected at their init, on both binaries.

On the base, each of those rejections is also counted as an accepted connection:

time      ws_connection_accepted  ws_connection_rejected
05:25:11                       2                       0
05:28:13                      18                      16

With this branch:

05:38:03                       1                       0
05:41:05                       1                      16

The handler also went on to start the per-connection clients. Across the 16 rejected connections on the base, the journal has 16 "starting hasura client" and 16 "starting gql-actions client", and the browser writer starts as well; with this branch there are none of them. No connection to Hasura is actually opened in either case: the upgrade count of the Hasura nginx and hasura_websocket_connections do not move during the 16 rejections. So on the base the cost is the goroutines and the wrong count, not traffic to Hasura.

One case that does not reach it, in case someone wonders: a tab left open when the meeting ends shows the session ended screen and does not reconnect, so it produces no rejected connection at all.

In a clean golang:1.27-bookworm container with only bbb-graphql-middleware, go build ./..., go vet ./... and go test -race -count=2 ./... pass on this branch.

@antobinary
antobinary merged commit 9a8545d into bigbluebutton:v4.0.x-develop Nov 20, 2026
37 checks passed
germanocaumo added a commit to germanocaumo/bigbluebutton that referenced this pull request Nov 21, 2026
Brings v4.0.x-develop to 932c31d: the merged bigbluebutton#26631 and the fixes that
followed it on 4.0 (bigbluebutton#26642 and bigbluebutton#26634 for the API conformance Tier 1
stack, bigbluebutton#26641 for the presentation conversion tests, bigbluebutton#26636 and bigbluebutton#26617
for the middleware limits, bigbluebutton#26581 for failed uploads), plus bigbluebutton#26583,
bigbluebutton#26548 and bigbluebutton#26615.

Resolutions:
- api-conformance env/tier1/copies.sha256: each hash matches the merged
  file. preinst is 4.1's own (0413ab4), so 4.1's line; start-template
  has 4.0.3's change on both lines now, so 4.0's line.
- docs new-features.md: 4.1's file, unchanged.

# Conflicts:
#	bigbluebutton-tests/api-conformance/env/tier1/copies.sha256
#	docs/docs/new-features.md
imdt-claudiop added a commit to imdt-claudiop/bigbluebutton that referenced this pull request Nov 26, 2026
On this base a connection rejected at init returns before
ws_connection_accepted is counted (since bigbluebutton#26617), but a connection
closed by the connection_init timeout is not followed by a return:
after the 4408 close the handler goes on, and the connection was
counted in ws_connection_accepted as well as in ws_connection_rejected.
The outcome of the init is now recorded in one place, before the
branch, and a rejected or timed-out connection is counted as rejected
only. The handler's flow is unchanged.

The tests drive connections through ConnectionHandler from a websocket
client: one rejected at init (param_missing), and one that sends
nothing until the init timeout, which is counted as accepted without
this change.

Co-authored-by: Tiago Jacobs <[email protected]>
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.

3 participants