Skip to content

Add configurable compatibility allowances to thrift audit - #3689

Draft
zsy056 wants to merge 1 commit into
apache:masterfrom
zsy056:codex/thrift-audit-compatibility-options
Draft

Add configurable compatibility allowances to thrift audit#3689
zsy056 wants to merge 1 commit into
apache:masterfrom
zsy056:codex/thrift-audit-compatibility-options

Conversation

@zsy056

@zsy056 zsy056 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add --audit-allow-optional-field-removal so explicit optional fields can be removed when intentionally enabled
  • add --audit-allow-required-field-to-default so required fields can move to default requiredness when intentionally enabled
  • keep default-field removal, required-field removal, default-to-required, and required-to-optional changes rejected
  • move configurable audit coverage into standalone .thrift fixtures
  • register the audit suite with both Automake and CMake, and exercise it in GitHub Actions

Compatibility validation

Generated separate C++ bindings for required and default requiredness and tested both directions with the binary protocol:

  • required writer -> default-requiredness reader: value 8675309 recovered
  • default-requiredness writer -> required reader: value 8675309 recovered
  • both serialized payloads were identical (8 bytes)

This confirms that removing explicit required while retaining default requiredness is wire-compatible for this transition.

Regression proof

In a disposable WSL2 checkout, I temporarily weakened the optional-removal guard so the option also allowed removal of a default-requiredness field. The registered CMake ThriftAuditTest failed on the intended negative case:

TEST FAILURE: default field removal remains rejected by optional removal option: expected exit code 2, got 0

After restoring the committed implementation, the same test passed.

Validation

  • CMake build and full ctest: 18/18 passed
  • rebased-head CMake ThriftAuditTest: passed
  • Autotools top-level make check: passed, including test/audit
  • perl -c test/audit/thrift_audit_test.pl: passed
  • git diff --check: passed

Checklist

  • Apache Jira ticket (not created for this contribution)
  • Single commit
  • No default audit behavior changed; compatibility allowances require explicit options
  • Test coverage added with standalone Thrift files

AI assistance

Generated-by: OpenAI Codex (GPT-5)

Client: cpp

Generated-by: OpenAI Codex (GPT-5)
@mergeable mergeable Bot added compiler testsuite build and general CI cmake, automake and build system changes github_actions Pull requests that update GitHub Actions code labels Jul 30, 2026
@Jens-G

Jens-G commented Jul 30, 2026

Copy link
Copy Markdown
Member

required fields can move to default requiredness when intentionally enabled

But you are aware that this breaks your contract? IOW that is what audit is designed to check.

@zsy056

zsy056 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

required fields can move to default requiredness when intentionally enabled

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build and general CI cmake, automake and build system changes compiler github_actions Pull requests that update GitHub Actions code testsuite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants