-
Notifications
You must be signed in to change notification settings - Fork 455
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
[query] Fix nil panic for error response for PromReadInstantHandler #1611
[query] Fix nil panic for error response for PromReadInstantHandler #1611
Conversation
false, | ||
), | ||
Handlers: testSetupHandlers{ | ||
Read: NewPromReadHandler(engine, tagOpts, limitsConfig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: think it might read a little nicer if these handlers were defined before the return statement; line breaks would probably look a bit more readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sg.
at1, value1, err := result.Data.Result[1].Value.parse() | ||
require.NoError(t, err) | ||
|
||
expected := mustPrettyJSON(t, fmt.Sprintf(` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Think it may be a little cleaner to flip this around; have expected be a vectorResult
and then just check equality between it and default json decoded result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure yeah.
"github.com/m3db/m3/src/query/block" | ||
"github.com/m3db/m3/src/query/test" | ||
"github.com/m3db/m3/src/query/util/logging" | ||
xtest "github.com/m3db/m3/src/x/test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: newline here
} | ||
|
||
result, err := read(ctx, h.engine, h.tagOpts, w, params) | ||
if err != nil { | ||
logger.Error("unable to fetch data", zap.Error(err)) | ||
httperrors.ErrorWithReqInfo(w, r, http.StatusBadRequest, rErr) | ||
httperrors.ErrorWithReqInfo(w, r, http.StatusInternalServerError, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂
setup := newTestSetup() | ||
promReadInstant := setup.Handlers.InstantRead | ||
|
||
storageErr := fmt.Errorf("storage err") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: errors.New()
instead of fmt.Errorf()
Codecov Report
@@ Coverage Diff @@
## master #1611 +/- ##
=========================================
- Coverage 72% 56% -16.1%
=========================================
Files 963 640 -323
Lines 80171 46993 -33178
=========================================
- Hits 57794 26329 -31465
+ Misses 18608 18569 -39
+ Partials 3769 2095 -1674
Continue to review full report at Codecov.
|
What this PR does / why we need it:
Fixes panic when returning a query error from PromReadInstantHandler, also adds some tests.
Special notes for your reviewer:
Does this PR introduce a user-facing and/or backwards incompatible change?:
Does this PR require updating code package or user-facing documentation?: