Skip to content

Fix 1988 - #1989

Merged
oberstet merged 4 commits into
crossbario:masterfrom
oberstet:fix_1988
Oct 18, 2026
Merged

oberstet merged 4 commits into
crossbario:masterfrom
oberstet:fix_1988

Conversation

@oberstet

Copy link
Copy Markdown
Contributor

fixes #1988

Add src/autobahn/wamp/test/test_wamp_payload_codec_error.py, which runs on
both backends (trial with USE_TWISTED, pytest with USE_ASYNCIO): an
ApplicationSession with a payload codec whose encode() raises must re-raise
the codec's exception from call(), and send nothing. session.log is not
mocked on purpose - a Mock has every method, so it would hide a logger
method that one backend lacks.

On Twisted the error is logged as a Failure by log.failure(), which trial
reports as a test error; the test flushes it (trial TestCase only), since
Twisted is not affected by crossbario#1988.

Defect shown: on asyncio, call() raises AttributeError
("'_TxaioLogWrapper' object has no attribute 'failure'") from
wamp/protocol.py:1950 instead of the codec's exception.

Local (asgard1): cpy314 + pypy311 - trial PASSED, pytest FAILED with that
AttributeError.

Expected CI result: RED - the asyncio/pytest runs (unit-tests on all five
Pythons, quality-checks) fail in test_call_reraises_payload_codec_error;
the Twisted/trial runs and all other jobs are green.

Note: This work was completed with AI assistance (Claude Code).
…hecker

The red commit 78b4d55 failed check-typing (ty, quality-checks job):
the test class used a base class chosen at import time
(twisted.trial.unittest.TestCase or unittest.TestCase), which ty sees as
a union type it cannot use as a base ("unsupported-base"). I had not run
`just check-typing` before pushing it.

Now the test body is a module-level function taking a
unittest.TestCase, called from one class per backend: a trial TestCase
under USE_TWISTED (it flushes the logged CodecError, as before), a
stdlib TestCase otherwise. The test itself is unchanged.

Local (asgard1): `just check-typing cpy314` passes; cpy314 + pypy311 -
trial PASSED, pytest FAILED with the AttributeError from
wamp/protocol.py:1950 (the crossbario#1988 defect).

Expected CI result: RED - only the asyncio/pytest runs (unit-tests on
all five Pythons, quality-checks) fail in
test_call_reraises_payload_codec_error; check-typing, the trial runs and
all other jobs are green.

Note: This work was completed with AI assistance (Claude Code).
…ackends

ApplicationSession.call() logged a payload codec failure with
self.log.failure(), which only the Twisted logger has: on asyncio the
except block itself raised AttributeError, so the codec's exception was
neither logged nor raised to the caller. Log it with log.error() and the
traceback from txaio.failure_format_traceback(txaio.create_failure()) -
the same pattern as the crossbario#1986 asyncio receive-path fix - which works on
both backends, then re-raise.

The other log.failure() calls in the code base are in Twisted-only
modules (autobahn/twisted/...); wamp/protocol.py had only this one.

Changelog bullet in the asyncio group.

Local (asgard1): full matrix green, 20/20 (cpy311-314 + pypy311 x
trial/pytest x NVX on/off), one more test passing per run than before;
the asyncio log line shows the procedure and the codec's traceback. Re-run after red (2)
restructured the test: still 20/20.
ruff check and `just check-typing cpy314` (ty) pass.

Expected CI result: GREEN - all jobs, including
test_call_reraises_payload_codec_error on both backends.

Note: This work was completed with AI assistance (Claude Code).
@oberstet
oberstet merged commit 36eb14e into crossbario:master Oct 18, 2026
53 checks passed
@oberstet
oberstet deleted the fix_1988 branch October 18, 2026 09:20
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.

asyncio: ApplicationSession.call() raises AttributeError instead of the payload codec error (log.failure() is Twisted-only)

1 participant