Skip to content

Commit 9bc72dc

Browse files
committed
Add proper error message for null result when value expected
Without this check, the code would proceed to call Normalize() on a null result, causing an unclear failure that doesn't explain the actual problem.
1 parent e852f43 commit 9bc72dc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

runner/runner.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ func validateResponseForSuccess(test TestCase, resp *Response) error {
233233
return nil
234234
}
235235

236+
if resp.Result.IsNullOrOmitted() {
237+
return fmt.Errorf("expected result with value, got null or omitted result")
238+
}
239+
236240
expectedNorm, err := test.ExpectedResponse.Result.Normalize()
237241
if err != nil {
238242
return fmt.Errorf("failed to normalize expected result: %w", err)

0 commit comments

Comments
 (0)