Skip to content

fix(core): fix waiter bug that caused it to return nil nil - #11418

Open
SerseusWasTaken wants to merge 1 commit into
mainfrom
fix/fix-wait-handler-nilnil-bug
Open

SerseusWasTaken wants to merge 1 commit into
mainfrom
fix/fix-wait-handler-nilnil-bug

Conversation

@SerseusWasTaken

Copy link
Copy Markdown
Contributor

Description

Fixes a bug in waithandlerhelper that caused some wait handlers to return (nil, nil).

It also introduces a way to prevent future wait handlers to return the wrong waitFinished state by overriding it to false in wait.go. The related regression test proves that the workaround works, while the other TestWaiterHelper_WaitWithContext test covers more of the waiter helper handler implementation.

Relates to STACKITTPR-844

Checklist

  • Issue was linked above
  • No generated code was adjusted manually (check comments in file header)
  • Changelogs
    • Changelog in the root directory was adjusted (see here)
    • Changelog(s) of the service(s) were adjusted (see e.g. here)
  • VERSION file(s) of the service(s) were adjusted
  • Code format was applied: make fmt
  • Examples were added / adjusted (see examples/ directory)
  • Unit tests got implemented or updated
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

@github-actions

Copy link
Copy Markdown

gorelease report

generated on Wed Sep 16 10:16:49 UTC 2026

Comment thread core/wait/wait.go
Comment on lines +105 to +108
// the error was retryable and got swallowed by h.handleError, so done represents a failed
// fetch rather than a finished action - poll again instead of returning
// otherwise we might return (nil, nil)
done = false

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.

This guard is debatable

Comment thread core/wait/wait_test.go
Comment on lines +389 to +427
// TestWaitWithContext_RetryableErrorReportedAsDone is a regression test for a bug where a checkFn
// that reports waitFinished=true alongside a retryable error caused WaitWithContext to return (nil, nil)
// instead of retrying, because `done` stayed true even after handleError swallowed the error.
func TestWaitWithContext_RetryableErrorReportedAsDone(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
type respType struct{ Name string }

numberCheckFnCalls := 0
checkFn := func() (waitFinished bool, response *respType, err error) {
numberCheckFnCalls++
if numberCheckFnCalls == 1 {
// here the return true is the offending line => should be false
return true, nil, &oapierror.GenericOpenAPIError{
StatusCode: RetryHttpErrorStatusCodes[0],
ErrorMessage: "temporary error",
}
}
return true, &respType{Name: "my-resource"}, nil
}
handler := AsyncActionHandler[respType]{
checkFn: checkFn,
throttle: 10 * time.Millisecond,
timeout: 5 * time.Second,
tempErrRetryLimit: 5,
}

resp, err := handler.WaitWithContext(context.Background())

if err != nil {
t.Errorf("expected no error, got %v", err)
}
if resp == nil || resp.Name != "my-resource" {
t.Errorf("expected a resolved response, got %v", resp)
}
if numberCheckFnCalls != 2 {
t.Errorf("expected checkFn to be called twice (initial + retry), got %d calls", numberCheckFnCalls)
}
})
}

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.

This regression test is not needed if we decide to get rid of the guard

@SerseusWasTaken
SerseusWasTaken marked this pull request as ready for review September 16, 2026 10:50
@SerseusWasTaken
SerseusWasTaken requested a review from a team as a code owner September 16, 2026 10:50
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.

1 participant