fix(backtest): a 202 on the execute poll no longer yields an empty result - #3
Merged
Conversation
…sult The API answers 202 with an empty body when a job is known but its result is not readable yet, so a successful response can legitimately carry no state. BacktestWorkflow dereferenced getState() inside the retry predicate. The failure is quiet, which is what makes it worth a regression test. The NullPointerException is raised inside Failsafe's result predicate and swallowed there: the retry does not match, the poll ends, and the caller is handed a null ResultMap for a backtest that actually completed -- the same "finished, and I could not find it" trap the 202 exists to prevent, moved to the client side. The status is now read through a null-safe accessor, so an absent state normalizes to IN_PROGRESS and the loop asks again under its existing timeout. Verified fail-first: reverting the guard fails the new test with a null result, not with a visible NPE.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Reads the execute-result status through a null-safe accessor, so a
202continues the poll instead of ending it.Why
The API answers
202with an empty body when a job is known but its result is not readable yet, so a successful response can legitimately carry nostate.BacktestWorkflowdereferencedgetState()inside the retry predicate.The failure is quiet, which is what makes it worth a regression test. The
NullPointerExceptionis raised inside Failsafe's result predicate and swallowed there: the retry simply does not match, the poll ends, and the caller is handed anullResultMapfor a backtest that actually completed — the same "finished, and I could not find it" trap the202exists to prevent, moved to the client side.Changes
statusOf(BacktestJobResult)returns the status ornull;StatusNormalizeralready mapsnulltoIN_PROGRESS, so the loop asks again under its existing timeout.202s (empty body, no state) before the real result.Validation
Full suite green (49 tests). Verified fail-first: reverting the guard fails the new test — and it fails with a null result rather than a visible NPE, which is exactly the point.