Skip to content

fix(bbb-graphql-middleware): Fix the findings of go vet and run the tests without an installed config - #26615

Merged
antobinary merged 2 commits into
bigbluebutton:v4.0.x-developfrom
imdt-claudiop:pr/middleware-vet-findings
Nov 20, 2026
Merged

antobinary merged 2 commits into
bigbluebutton:v4.0.x-developfrom
imdt-claudiop:pr/middleware-vet-findings

Conversation

@imdt-claudiop

Copy link
Copy Markdown
Contributor

What does this PR do?

Two things kept the middleware's own checks from passing in a clean checkout: go vet ./... reported findings, and go test ./... failed in internal/websrv on a machine without the middleware installed. This PR fixes both.

  • The error is built with errors.New, the two log calls use Debugf and Error, and the rate limiter's context is cancelled as soon as the wait returns. The debug log lines now show their values.
  • A small test package, config/testconfig, 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; internal/websrv does so here. Its comment explains why it is initialized before the packages that read the configuration. Production code does not import it.

Closes Issue(s)

None.

Motivation

  • go vet ./... reported printf-style calls whose format did not match their arguments, and a discarded cancel function:
    • internal/akka_apps/client.go: an error built with fmt.Errorf from a non-constant message;
    • internal/bbb_web/client.go and internal/hasura/conn/reader/reader.go: logrus Debug called with a format string and arguments, so the values were not formatted;
    • internal/gql_actions/client.go and internal/hasura/conn/writer/writer.go: logrus Errorf called with a non-constant message;
    • internal/hasura/conn/writer/writer.go: the cancel function of the query rate limiter's timeout context was discarded.
  • Some packages read the configuration when they are initialized, from /usr/share/bbb-graphql-middleware/config.yml and an override in /etc/bigbluebutton. A test binary of such a package fails before any test runs on a machine without the middleware installed, so go test ./... failed in internal/websrv.

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 ./...
  • Before: go vet ./... reports the findings above and go test ./... fails in internal/websrv.
  • With this PR: the three commands pass. The first commit alone still fails go test in internal/websrv on a machine without the installed configuration, as the base does; the second commit fixes that.

More

Docs not affected. The middleware PRs that follow are built on this one.

imdt-claudiop and others added 2 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]>
@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 changes add a test-only package that sets the repository’s default configuration path and a nonexistent override path. The websrv tests blank-import the package. Middleware updates construct unauthorized errors with errors.New, correct log method usage, and cancel the rate-limiter timeout context after waiting.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: gustavotrott

Merge Risk: Minimal · up to d25b4

This change fixes go vet findings and lets the websrv tests run without an installed middleware configuration. Production behavior is essentially unchanged apart from correct log formatting and timeout context cleanup. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description check Passed The description is directly related to the changeset. It explains the go vet fixes (errors.New, Debugf, Error, cancelled rate-limiter context) and the new config/testconfig package used by the websrv …
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 the two real aspects of the changeset: fixing go vet findings and making tests run without an installed config. The raw summary confirms both: errors.New, Debugf/Error log fixes, conte…
Full details: Description check

Explanation

The description is directly related to the changeset. It explains the go vet fixes (errors.New, Debugf, Error, cancelled rate-limiter context) and the new config/testconfig package used by the websrv tests, and it gives reproduction and test steps.

Full details: Title check

Explanation

The title names the two real aspects of the changeset: fixing go vet findings and making tests run without an installed config. The raw summary confirms both: errors.New, Debugf/Error log fixes, context cancellation, and the new config/testconfig package that lets tests load the repository config. The title does not name every fix (for example, the context cancellation), which is acceptable. It also uses the conventional fix(scope): prefix. The title is specific enough to pass.

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: 515752ed-655b-42fb-9737-8334ea637526
Commits

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

Files selected for processing: 7

  • 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/testconfig_test.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 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 Fix the findings of go vet and run the tests without an installed config fix(bbb-graphql-middleware): Fix the findings of go vet and run the tests without an installed config Nov 19, 2026

@paultrudel paultrudel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, this looks good to me. I ran it on a machine without the middleware installed, with Go 1.27.0:

  • base (e2dab6e): go vet ./... reports the six findings. go test -race -count=2 ./... fails in internal/websrv on the missing /usr/share/bbb-graphql-middleware/config.yml, and also in five other packages, because the printf check that go test runs itself fails on the same calls.
  • head (d25b4ae): go build, go vet and go test -race -count=2 ./... all pass.

The vet fixes are correct as they are. errors.New(message) also stops a % in the akka-apps message from being read as a format directive, and the rate limiter's context is now cancelled right after Wait returns.

None of the points below blocks the merge:

  1. testconfig relies on the source path recorded at build time. runtime.Caller(0) returns a module-relative path when the tests are built with -trimpath, so go test -trimpath ./internal/websrv/ fails again with Error while loading config file (bbb-graphql-middleware/config/config.yml). I reproduced it. Nothing in the repo uses -trimpath, so this is about robustness only. Walking up from os.Getwd() to the directory that holds go.mod would avoid it (go test runs in the package directory). At the least, checking the ok result would give a clear error instead of a path relative to ..
  2. The redirect depends on init order. The package comment explains it well, and the order follows the spec. Still, a later package that reads the configuration at init and whose import path sorts before config/testconfig (anything under cmd/, or a config/schema) would read the installed config first, and GetConfig's sync.Once would keep that result. Making the remaining package-level reads lazy, as rediscli.go already does, would remove that dependency. That could fit one of the middleware PRs that build on this one.
  3. Optional: since config/testconfig is an ordinary package, a stray import from non-test code would redirect the server's config. A if !testing.Testing() { panic(...) } in its init would rule that out.
  4. Tiny: the Debugf at internal/bbb_web/client.go:94 logs through the global log, so those lines lack the connection fields that logger adds to the lines around them.

No CI job runs go vet or go test for the middleware yet. Is that coming in one of the follow-up PRs?

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

Where the formatting defect shows. internal/bbb_web/client.go:94 runs on every authorized connection init, so once when a user joins and once on every websocket reconnection, five lines per join. On the base the format verbs are not applied and the key and the value come out glued together:

"msg": "%s: %s\nx-moderatorfalse"
"msg": "%s: %s\nx-userid<redacted>"

With this branch:

"msg": "x-moderator: false"
"msg": "x-userid: <redacted>"

Where the discarded cancel shows. Every subscribe builds a 30 s timeout context in internal/hasura/conn/writer/writer.go whose cancel function is dropped, so its timer and its entry in the parent context stay alive until the deadline passes or the Hasura connection is cancelled. In a trace log of 15 browser connections on the base, each connection sent 31 to 56 subscribe frames (median 35), and a single Hasura reconnection resent up to 26 of them, so one connection can hold tens of those timers at a time. With this branch the cancel runs as soon as the wait returns.

And the checks themselves, in a clean golang:1.27-bookworm container with only bbb-graphql-middleware, at the same commit of v4.0.x-develop:

go vet ./...    exits 1, with the six findings listed in the PR
go test ./...   fails in six packages: five do not build, because go test runs vet,
                and internal/websrv fails on the missing configuration file

With this branch, go build ./..., go vet ./... and go test -race -count=2 ./... all pass in the same container.

@antobinary
antobinary merged commit 5ea1525 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
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