-
Notifications
You must be signed in to change notification settings - Fork 66
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
API-34957 v1 error formatter update #16197
API-34957 v1 error formatter update #16197
Conversation
* Adds a test for any errors still saved with wrapper * Adds two test to custom_error_spec for testing error format scenarios modified: modules/claims_api/spec/requests/v1/claims_request_spec.rb modified: modules/claims_api/spec/sidekiq/claim_custom_error_spec.rb
Generated by 🚫 Danger |
detail: "claims_api-526-#{@method}, errors: #{errors}", claim: @claim&.id) | ||
end | ||
def raise_backend_exception(source, error, key = 'EVSS') | ||
error_details = get_error_details(error) |
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.
I think this is redundant logic. we can just pass e.original_body
to line :34 and get the same result.
(byebug) @error.original_body
{:messages=>[{:key=>"header.va_eauth_birlsfilenumber.Invalid", :severity=>"ERROR", :text=>"Size must be between 8 and 9"}]}
30: error_details = get_error_details(error)
31:
=> 32: raise ::Common::Exceptions::BackendServiceException.new(
33: key,
34: { source: },
35: error&.original_status,
36: error_details
(byebug) error_details
[{:key=>"header.va_eauth_birlsfilenumber.Invalid", :severity=>"ERROR", :text=>"Size must be between 8 and 9"}]
actually this throws an error in the validate. without the :messages
.
"code": "500",
"status": "500",
"meta": {
"exception": "no implicit conversion of Symbol into Integer",
=> 180: error_details = e&.original_body&.[](:messages)
181: raise ::Common::Exceptions::UnprocessableEntity.new(errors: format_526_errors(error_details))
182: rescue ::Common::Exceptions::GatewayTimeout,
183: ::Timeout::Error,
184: ::Faraday::TimeoutError,
(byebug) e&.original_body&.[](:messages)
*** TypeError Exception: no implicit conversion of Symbol into Integer
nil
if we pass the original body we can just change the claim_establisher
to record evss_response = e.messages
. unless you saw a differing format in the submit call?
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.
@FonzMP Good catch. I think there is a different format in the claims_controller
. I think the fix might actually be to remove the line error_details = e&.original_body&.[](:messages)
in the V1 disability_compensation_controller
. This was added when building the V2 validate service because of the different format from the docker container. I think the current update renders this unnecessary now. The error here and in the V1 claims_controller
should be in the same format I believe, so not having :messages
over there (v1 claims_controller formatter ) would mean we no longer want to account for it over here too I suspect. Thoughts?
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.
still don't know if I'm quite following because the docker response is the same for v1 and v2. no formatting has been changed. plus the below logic for error_details
just extracts the :messages
we get from the container? Anywho, it behaves in the same manner, so 🤷
(byebug) error.original_body
{:messages=>[{:key=>"header.va_eauth_birlsfilenumber.Invalid", :severity=>"ERROR", :text=>"Size must be between 8 and 9"}]}
(byebug) error_details
[{:key=>"header.va_eauth_birlsfilenumber.Invalid", :severity=>"ERROR", :text=>"Size must be between 8 and 9"}]
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.
I think I see where you're driving that.. it's because of the loss of the ability to call e.messages
from the former error.
Service Exception being raised
Error class
parent giving us the goods
this structure essentially extracted one level out... hence the use of e.messages
…es key since custom error will handle that and claims controller also does not look for that in its formatter
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.
Summary
claim_establisher
there was a wrapper being placed around::Common::Exceptions::BackendServiceException
when they were rescued. That wrapper set thekey:
value as an integer. That caused the error formatter method in theclaims_controller
,format_evss_errors
, to break when someone would try to view that claim because.gsub
was being called on that value (integer). So it would return aclaim not found
error when the claim was found it's evss response just broke the formatter.evss_response
, formats theevss_responses
so that they have the correct information, and also updates theformat_evss_errors
method in theclaims_controller
so it can display any previously saved claims with the incorrect wrapper.Related issue(s)
API-33934, failure
API-34957
Testing done
Testing Notes
evss_service/base
will be a good test. Make sure to turn off mocking.Once the claim gets saved with the error you will want to then view the claim via
http://localhost:3000/services/claims/v1/claims/:claim_id
to see the evss response error message saved on the claimThe original cause of this issue as stated before was a wrapper that saved an error with a
key:
value that was an integer. If you want to mirror this behavior to test that it will now handle showing these claims, you can take a claim you have saved in your DB and make itsevss_response
equal to the error below. You should still be able to view the claim and see the error message, the details will not be the same because of the wrapper but it should not returnclaim not found
Screenshots
Note: Optional
What areas of the site does it impact?
Acceptance criteria
Requested Feedback
(OPTIONAL)What should the reviewers know in addition to the above. Is there anything specific you wish the reviewer to assist with. Do you have any concerns with this PR, why?