Skip to content

Fix context propagation in execute operations#459

Open
timothyF95 wants to merge 8 commits into
mainfrom
fix/ctx-propagation-execute
Open

Fix context propagation in execute operations#459
timothyF95 wants to merge 8 commits into
mainfrom
fix/ctx-propagation-execute

Conversation

@timothyF95
Copy link
Copy Markdown
Contributor

@timothyF95 timothyF95 commented May 28, 2026

@timothyF95 timothyF95 marked this pull request as ready for review May 28, 2026 18:34
@timothyF95 timothyF95 requested a review from a team as a code owner May 28, 2026 18:34
j-nowak
j-nowak previously approved these changes May 29, 2026
@timothyF95 timothyF95 removed the request for review from lawrencexia May 29, 2026 12:27
Comment thread cmd/workflow/deploy/deploy.go Outdated
Comment on lines +136 to +144
// executionContext returns the context from Execute(), or context.Background()
// when handler methods are invoked directly in unit tests.
func (h *handler) executionContext() context.Context {
if h.execCtx != nil {
return h.execCtx
}
return context.Background()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't like the pattern, where in the production code we have a branch for testing. It is a code smell and creates a higher risk for bugs and issues.

Why can't we have one of those:

  1. Create handler with context as constructor param
  2. Pass ctx as a function params where needed and then don't store it as a handler field?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it would be better to pass the ctx as a parameter. It did make testing challenging

Comment thread cmd/workflow/deploy/deploy.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a code smell, and can cause a lot of weird bugs in the future. We shouldn't mutate a field like that.

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.

2 participants