Skip to content

Fix 2252 - #2263

Merged
oberstet merged 3 commits into
crossbario:masterfrom
oberstet:fix_2252
Jul 17, 2026
Merged

Fix 2252#2263
oberstet merged 3 commits into
crossbario:masterfrom
oberstet:fix_2252

Conversation

@oberstet

Copy link
Copy Markdown
Contributor

fixes #2252 - with proper two-phase / red-green TDD

oberstet added 3 commits July 17, 2026 11:16
…[512, 16MB] (crossbario#2252)

check_rawsocket_options() reuses the WebSocket-shaped
check_transport_max_message_size(), which accepts [1, 64MB]. But the RawSocket
transport hands the value to autobahn's WampRawSocketFactory.setProtocolOptions,
which asserts [512, 2**24] — the range the WAMP RawSocket handshake can encode
(length exponent 2**(9+n), n in [0,15]). So a config like
max_message_size=100 or max_message_size=32000000 passes 'crossbar check' and
then AssertionErrors at transport start: a false green.

Add CheckRawsocketTests asserting RawSocket rejects < 512 and > 16 MB (incl. the
511 and 2**24+1 boundaries), accepts the 512 and 2**24 boundaries, and that the
split leaves WebSocket's own [1, 64MB] range unaffected. RED as expected: the
four out-of-range assertions fail (InvalidConfigException not raised); the two
boundary-accept cases and the WebSocket guard already pass.

Note: This work was completed with AI assistance (Claude Code).
Give RawSocket its own max_message_size validator instead of reusing the
WebSocket-shaped check_transport_max_message_size() ([1, 64MB]). The root cause
was one shared validator applied to two transports with genuinely different
constraints: WAMP RawSocket encodes the receive limit as a length exponent
2**(9+n), n in [0,15], so autobahn's WampRawSocketFactory.setProtocolOptions
asserts [512, 2**24]. A config in the gap passed 'crossbar check' and then
AssertionError-ed at transport start (a false green).

- checkconfig.py: add check_transport_rawsocket_max_message_size() over
  [RAWSOCKET_MAX_MESSAGE_SIZE_MIN=2**9, RAWSOCKET_MAX_MESSAGE_SIZE_MAX=2**24];
  point check_rawsocket_options() at it; clarify that
  check_transport_max_message_size() is the WebSocket ([1, 64MB]) validator.
  The bounds are fixed by the RawSocket handshake (not autobahn being fussy), so
  they cannot drift; the comment ties them to autobahn's assert.
- docs/RawSocket-Transport.rst: correct the range (was 1-64MB) and the default
  (was 128kB; the real default is 16MB) and note the value is the uncompressed
  message size.
- changelog: 26.7.1 entry.

Turns CheckRawsocketTests green (7/7); WebSocket's own range is unaffected. Full
local gate: ruff + ty clean, test_checkconfig 40 passed, Sphinx dummy build
clean on the changed pages.

Note: This work was completed with AI assistance (Claude Code).
@oberstet

Copy link
Copy Markdown
Contributor Author

phase 1 ("red"), eg https://github.com/crossbario/crossbar/actions/runs/29571479798/job/87856100809?pr=2263

[FAIL]
Traceback (most recent call last):
  File "/home/runner/work/crossbar/crossbar/.venvs/cpy311/lib/python3.11/site-packages/crossbar/test/test_checkconfig.py", line 479, in test_rejects_above_16mb
    with self.assertRaises(checkconfig.InvalidConfigException):
  File "/home/runner/work/crossbar/crossbar/.venvs/cpy311/lib/python3.11/site-packages/twisted/trial/_synctest.py", line 319, in __exit__
    self._testCase.fail(
twisted.trial.unittest.FailTest: InvalidConfigException not raised (None returned)

crossbar.test.test_checkconfig.CheckRawsocketTests.test_rejects_above_16mb
===============================================================================
[FAIL]
Traceback (most recent call last):
  File "/home/runner/work/crossbar/crossbar/.venvs/cpy311/lib/python3.11/site-packages/crossbar/test/test_checkconfig.py", line 471, in test_rejects_below_512
    with self.assertRaises(checkconfig.InvalidConfigException):
  File "/home/runner/work/crossbar/crossbar/.venvs/cpy311/lib/python3.11/site-packages/twisted/trial/_synctest.py", line 319, in __exit__
    self._testCase.fail(
twisted.trial.unittest.FailTest: InvalidConfigException not raised (None returned)

crossbar.test.test_checkconfig.CheckRawsocketTests.test_rejects_below_512
===============================================================================
[FAIL]
Traceback (most recent call last):
  File "/home/runner/work/crossbar/crossbar/.venvs/cpy311/lib/python3.11/site-packages/crossbar/test/test_checkconfig.py", line 483, in test_rejects_just_above_16mb
    with self.assertRaises(checkconfig.InvalidConfigException):
  File "/home/runner/work/crossbar/crossbar/.venvs/cpy311/lib/python3.11/site-packages/twisted/trial/_synctest.py", line 319, in __exit__
    self._testCase.fail(
twisted.trial.unittest.FailTest: InvalidConfigException not raised (None returned)

crossbar.test.test_checkconfig.CheckRawsocketTests.test_rejects_just_above_16mb
===============================================================================
[FAIL]
Traceback (most recent call last):
  File "/home/runner/work/crossbar/crossbar/.venvs/cpy311/lib/python3.11/site-packages/crossbar/test/test_checkconfig.py", line 475, in test_rejects_just_below_512
    with self.assertRaises(checkconfig.InvalidConfigException):
  File "/home/runner/work/crossbar/crossbar/.venvs/cpy311/lib/python3.11/site-packages/twisted/trial/_synctest.py", line 319, in __exit__
    self._testCase.fail(
twisted.trial.unittest.FailTest: InvalidConfigException not raised (None returned)

crossbar.test.test_checkconfig.CheckRawsocketTests.test_rejects_just_below_512
-------------------------------------------------------------------------------
Ran 358 tests in 0.386s

FAILED (skips=91, expectedFailures=3, failures=4, successes=260)
error: recipe `test-trial` failed with exit code 1
Error: Process completed with exit code 1.
image

@oberstet

Copy link
Copy Markdown
Contributor Author

phase 2 ("green"), eg

src/crossbar/test/test_checkconfig.py::CheckRawsocketTests::test_rejects_above_16mb PASSED
src/crossbar/test/test_checkconfig.py::CheckRawsocketTests::test_rejects_below_512 PASSED
src/crossbar/test/test_checkconfig.py::CheckRawsocketTests::test_rejects_just_above_16mb PASSED
src/crossbar/test/test_checkconfig.py::CheckRawsocketTests::test_rejects_just_below_512 PASSED
image

@oberstet
oberstet merged commit 46c782d into crossbario:master Jul 17, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant