Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix encoding bug to index context header in search attributes #6148

Merged
merged 2 commits into from
Jun 26, 2024

Conversation

shijiesheng
Copy link
Contributor

What changed?

json marshal raw string bytes before store in search attributes

Why?

Context Header stores the raw string bytes; but search attributes should store json strings rather than raw string bytes. Otherwise, it will cause unmarshal error in creating visibility message.

How did you test it?

unit test

Potential risks

Release notes

Documentation Changes

searchAttr = appendContextHeaderToSearchAttributes(searchAttr, attributes.Header.Fields, t.config.ValidSearchAttributes())
// fail open to avoid blocking the task processing
if newSearchAttr, err := appendContextHeaderToSearchAttributes(searchAttr, attributes.Header.Fields, t.config.ValidSearchAttributes()); err != nil {
t.logger.Error("unable to parse search attributes", tag.Error(err))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: inconsistent error message in active/passive executors. I'd go with: "failed to add headers to search attributes"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

@@ -1978,8 +1979,12 @@ func createRecordWorkflowExecutionStartedRequest(
}
var searchAttributes map[string][]byte
if enableContextHeaderInVisibility {
contextValueJsonString, err := json.Marshal("contextValue")
if err != nil {
panic(err) // must not happen in tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: pass testing.T here and call t.Fatal instead of panic

@shijiesheng shijiesheng enabled auto-merge (squash) June 26, 2024 22:50
@shijiesheng shijiesheng merged commit 34cfbb3 into cadence-workflow:master Jun 26, 2024
19 checks passed
@coveralls
Copy link

coveralls commented Jun 26, 2024

Pull Request Test Coverage Report for Build 019056be-55a4-4346-b869-f5fdf9d38650

Details

  • 15 of 19 (78.95%) changed or added relevant lines in 3 files are covered.
  • 31 unchanged lines in 9 files lost coverage.
  • Overall coverage increased (+0.004%) to 71.547%

Changes Missing Coverage Covered Lines Changed/Added Lines %
service/history/task/transfer_active_task_executor.go 5 6 83.33%
service/history/task/transfer_standby_task_executor.go 5 6 83.33%
service/history/task/transfer_task_executor_base.go 5 7 71.43%
Files with Coverage Reduction New Missed Lines %
common/task/weighted_round_robin_task_scheduler.go 2 89.05%
common/task/fifo_task_scheduler.go 2 85.57%
common/util.go 2 91.84%
service/history/task/task.go 3 84.81%
service/history/handler/handler.go 3 96.2%
service/history/task/timer_standby_task_executor.go 3 85.63%
service/matching/tasklist/task_reader.go 4 77.19%
service/history/task/transfer_standby_task_executor.go 6 86.23%
service/history/execution/cache.go 6 74.61%
Totals Coverage Status
Change from base Build 0190508e-3f7e-4c0d-b546-4eaa2a2045f1: 0.004%
Covered Lines: 107099
Relevant Lines: 149690

💛 - Coveralls

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.

3 participants