fix(featureflags): use proto entity and proto json serializer#7708
fix(featureflags): use proto entity and proto json serializer#7708shijiesheng wants to merge 4 commits intocadence-workflow:masterfrom
Conversation
Signed-off-by: Shijie Sheng <liouvetren@gmail.com>
Signed-off-by: Shijie Sheng <liouvetren@gmail.com>
| SupportsConsistentQuery(clientImpl string, clientFeatureVersion string) error | ||
| SupportsRawHistoryQuery(clientImpl string, clientFeatureVersion string) error | ||
| SupportsWorkflowAlreadyCompletedError(clientImpl string, clientFeatureVersion string, featureFlags shared.FeatureFlags) error | ||
| SupportsWorkflowAlreadyCompletedError(clientImpl string, clientFeatureVersion string, featureFlags apiv1.FeatureFlags) error |
There was a problem hiding this comment.
🚨 Bug: Interface change breaks handler_test.go mock expectations
The VersionChecker interface change from shared.FeatureFlags to apiv1.FeatureFlags in SupportsWorkflowAlreadyCompletedError was not propagated to service/frontend/api/handler_test.go. That file (lines 4748 and 4752) still passes shared.FeatureFlags{} to the gomock expectation:
s.mockVersionChecker.EXPECT().SupportsWorkflowAlreadyCompletedError("impl-header", "feature-version", shared.FeatureFlags{}).Return(nil)
s.mockVersionChecker.EXPECT().SupportsWorkflowAlreadyCompletedError("impl-header", "feature-version", shared.FeatureFlags{}).Return(errors.New("error"))While this compiles (gomock recorder uses any typed parameters), at runtime gomock uses reflect.DeepEqual to match expected vs actual arguments. The actual code path now produces apiv1.FeatureFlags{} (from GetFeatureFlagsFromHeader), which will never match shared.FeatureFlags{} — these are entirely different Go types. This will cause the TestNormalizeVersionedErrors test to panic with an unexpected call error.
Fix: Update service/frontend/api/handler_test.go to use apiv1.FeatureFlags{} at both lines, and update its imports accordingly.
Was this helpful? React with 👍 / 👎
There was a problem hiding this comment.
No it doesn't. handler doesn't directly mock on this interface but instead use the versionChecker_mock, which is already changed
There was a problem hiding this comment.
You're correct that versionChecker_mock.go was updated with the proto type. However, the test expectations in handler_test.go still use shared.FeatureFlags{}.
Details
At handler_test.go:4748 and 4752:
s.mockVersionChecker.EXPECT().SupportsWorkflowAlreadyCompletedError("impl-header", "feature-version", shared.FeatureFlags{}).Return(nil)This needs to be updated to:
s.mockVersionChecker.EXPECT().SupportsWorkflowAlreadyCompletedError("impl-header", "feature-version", apiv1.FeatureFlags{}).Return(nil)The mock interface signature was correctly updated, but the test code that uses the mock wasn't updated to match. This is what's causing the gomock type mismatch error in CI.
| ) | ||
|
|
||
| // ToClientFeatureFlags returns Cadence client FeatureFlags version of idl.FeatureFlags | ||
| func ToClientFeatureFlags(featureFlags *shared.FeatureFlags) client.FeatureFlags { |
Signed-off-by: Shijie Sheng <liouvetren@gmail.com>
Code Review ✅ Approved 1 resolved / 1 findingsClean migration from Thrift to Proto FeatureFlags with proper serialization, consistent type updates across all consumers, and good test coverage including round-trip validation. Previous finding about handler_test.go mock mismatch was a false positive — all types are properly updated. ✅ 1 resolved
Rules ❌ No requirements metRepository Rules
Tip Comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
What changed?
Use proto entity of
FeatureFlagsinstead so it's consistent across languages. It's backward/forward compatible because the proto json marshaler returns the same result with thrift IDL by cadence-workflow/cadence-idl#245Why?
Proto has better language consistency than thrift.
How did you test it?
Added Unit Test to make sure the thrift marshaled json string can be deserialized into Proto entity.
Potential risks
Release notes
Documentation Changes
Reviewer Validation
PR Description Quality (check these before reviewing code):
go testinvocation)