Add configurable compatibility allowances to thrift audit - #3689
Conversation
But you are aware that this breaks your contract? IOW that is what audit is designed to check. |
Hi Jens I was using thrift as the internal RPC implementation of a micro-service, for this scenario, the contract is the client API of our micro-service, not the thrift definition itself. I found audit to be externally helpful to prevent issues on wire protocol incompatibility, it is used as part of a check-in gate. However, over the years, things have changed enough that we have to remove some optional and slowly deprecate some required fields. The current audit mode doesn’t provide the flexibility and we also definitely don’t want to drop audit entirely in the check-in gate. So I suppose if these relaxations are behind some command line option and is default to off, it should be safe for all existing users while still provide flexibility? Thanks |
Code reviewFound 3 issues:
Lines 8 to 18 in 194dcab Reproduced with 0.25.0 on
The compatibility validation in the PR description used C++ with an Suggest scoping "wire-compatible" to the first bullet and documenting the required rollout order for the second: every reader must be off
Lines 15 to 26 in 194dcab
thrift/compiler/cpp/src/thrift/audit/t_audit.cpp Lines 360 to 365 in 194dcab 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Client: cpp Generated-by: OpenAI Codex (GPT-5)
194dcab to
e43c055
Compare
Summary
--audit-allow-optional-field-removalso explicitly optional fields can be removed when intentionally enabled--audit-allow-required-field-to-defaultas a binding-dependent audit suppression.thriftfilesCompatibility behavior
Removing an explicitly optional field is wire-compatible.
Changing
requiredto default requiredness is not universally wire-compatible. Local generated-code validation showed:stringround-tripped into a required readerstringmay remainnulland be omitted; an older required reader then rejects the payloadUsers enabling
--audit-allow-required-field-to-defaultmust verify every binding and field type and upgrade all readers away from explicitrequiredbefore deploying writers that may omit it. The option also applies to service arguments; omission may fail before the handler runs. Explicitrequiredinthrowsis illegal and normalized by the parser, so throws clauses are not affected.Regression proof
In a disposable WSL2 source copy, changing the old service fixture from
required stringto default requiredness made the suite fail:Restoring the fixture made it pass.
Validation
make -C test/audit check: passed (1 test passed)ThriftAuditTest: passedperl -c test/audit/thrift_audit_test.pl: passedgit diff --check: passedmake style: blocked by pre-existing codespell findings outside this PRChecklist
AI assistance
Generated-by: OpenAI Codex (GPT-5)