Skip to content

Regression test for THRIFT-4002: Immutable exception deserialization#3349

Merged
Jens-G merged 1 commit intoapache:masterfrom
Jens-G:THRIFT-4002-immutable-exception-deserialization
Mar 20, 2026
Merged

Regression test for THRIFT-4002: Immutable exception deserialization#3349
Jens-G merged 1 commit intoapache:masterfrom
Jens-G:THRIFT-4002-immutable-exception-deserialization

Conversation

@Jens-G
Copy link
Member

@Jens-G Jens-G commented Mar 19, 2026

Client: py
Patch: Jens Geyer
Generated-by: Opencode big-pickle

This test verifies that immutable structs (including exceptions, which are immutable by default since Thrift 0.14.0) can be properly deserialized without triggering the setattr TypeError.

The bug manifests when:

  1. A struct class is marked immutable (has setattr that raises TypeError)
  2. Thrift's deserialization tries to set attributes via setattr instead of using the kwargs constructor

Test coverage:

  • Immutable exception creation and hashability
  • Immutable exception blocks modification/deletion
  • Round-trip serialization/deserialization with TBinaryProtocol
  • Round-trip serialization/deserialization with TCompactProtocol
  • Accelerated protocol tests (C extension) when available

Related: THRIFT-4002, THRIFT-5715

@mergeable mergeable bot added the python label Mar 19, 2026
@Jens-G Jens-G self-assigned this Mar 20, 2026
Client: py
Patch: Jens Geyer
Generated-by: Opencode big-pickle

This test verifies that immutable structs (including exceptions, which are immutable by default since Thrift 0.14.0) can be properly deserialized without triggering the __setattr__ TypeError.

The bug manifests when:
1. A struct class is marked immutable (has __setattr__ that raises TypeError)
2. Thrift's deserialization tries to set attributes via setattr instead of using the kwargs constructor

Test coverage:
- Immutable exception creation and hashability
- Immutable exception blocks modification/deletion
- Round-trip serialization/deserialization with TBinaryProtocol
- Round-trip serialization/deserialization with TCompactProtocol
- Accelerated protocol tests (C extension) when available

Related: THRIFT-4002, THRIFT-5715
@Jens-G Jens-G force-pushed the THRIFT-4002-immutable-exception-deserialization branch from db99552 to 2dc4dbb Compare March 20, 2026 23:57
@Jens-G Jens-G merged commit 98034d1 into apache:master Mar 20, 2026
8 of 9 checks passed
@Jens-G Jens-G deleted the THRIFT-4002-immutable-exception-deserialization branch March 21, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant