-
Notifications
You must be signed in to change notification settings - Fork 239
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
[YUNIKORN-2123] Modify json.Unmarshal error message #698
Conversation
Modifying the json.Unmarshal error message to better explain the failure of the specific function.
@makinyemi Thank you for the PR. |
@steinsgateted No problem! Ok, were you thinking unified in the sense of adding some sort of reusable function or constant string that we could format as needed to substitute for all of the occurrences of "failed to unmarshal..."? |
Introduce a const something like this. Also you can introduce constants for "Incorrect Status code" |
Codecov Report
@@ Coverage Diff @@
## master #698 +/- ##
==========================================
+ Coverage 77.63% 77.69% +0.05%
==========================================
Files 80 80
Lines 13271 13320 +49
==========================================
+ Hits 10303 10349 +46
- Misses 2648 2650 +2
- Partials 320 321 +1 see 9 files with indirect coverage changes 📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today! |
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.
-1. Every one of of the new messages is incorrect. It's the YAPIError structure that we're attempting to parse (Contains StatusCode, Message, Description). All of these functions are used to test error handling, and we assert in each of them that the error object is parsed correctly. Just change every message to "failed to unmarshal error response from response body".
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.
Now you've got additional changes that are not error handling. You need to pay attention to the context for each one.
Thanks for the feedback. Will reset and go back through |
Added a const variable for Unmarshal failure message for the error handling test and substitued occurences of literal strings.
cd7f278
to
96a26e9
Compare
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.
+1, pending precommit checks.
@makinyemi @manirajv06 @craigcondit |
Similar to my last commit? Make a constant for specific test functions? |
Some functions error message use string literals while others use constant variables available in the webservice pacakge. I replaced the hard coded messages with the corresponding constants. Closes: apache#699 Signed-off-by: Manikandan R <[email protected]>
…es API (apache#700) Closes: apache#700 Signed-off-by: Craig Condit <[email protected]>
Modified "failed to unmarshl..." error messages to use const message. Updated existing test by appending failure related to unmarshaling.
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.
Just change every message to "failed to unmarshal error response from response body".
Similar to my last commit? Make a constant for specific test functions?
@makinyemi @craigcondit
Thank you.
I think it's like @craigcondit said.
Replace all messages with unmarshalError.
No need to retain the original DAONAME part.
pkg/webservice/handlers_test.go
Outdated
@@ -48,6 +48,8 @@ import ( | |||
"github.com/apache/yunikorn-scheduler-interface/lib/go/si" | |||
) | |||
|
|||
const UnmarshalError = "Failed to unmarshal error response from response body" |
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.
UnmarshalError -> unmarshalError
@steinsgateted I did something similar to that in a previous commit that i reverted where @craigcondit mentioned in the above comment
If i understand correctly, as @craigcondit explained it certain test were testing for specific failure and the messages reflected the error they were handling. If i am mistaken i can definitely make the corrections |
Changed const UnmarshalError to unmarshalError
@steinsgateted @craigcondit Actually, I remember now. I added DAOInfo to every message, which was wrong. |
@makinyemi Thank you
we could add two new consts:
|
@makinyemi @manirajv06 @craigcondit Thank you.
|
What I think is that far too much time and effort has been spent on this. We're talking about the wording of a diagnostic message echoed by test cases when they fail (which they basically never do). Pick something reasonable and go with it. |
Modified unmarshalError and added statusCodeError and jsonMessageError constants
@makinyemi @craigcondit Thank you. +1 |
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.
+1
What is this PR for?
Modifying the json.Unmarshal error message to better explain the failure of the specific function.
What type of PR is it?
Todos
What is the Jira issue?
https://issues.apache.org/jira/browse/YUNIKORN-2123
How should this be tested?
Screenshots (if appropriate)
n/a
Questions:
n/a