Skip to content
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

Convert http errors to json #167

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

IamAlecYoung
Copy link

What problem does the pull request solve?

When the Notify service throws a 'NotifyClientException' Exception, the returned string is unparsable due to inconsistent json formatting.

Examples below:

{"Status code 400. Error: {"errors":[{"error":"BadRequestError","message":"Can\u2019t send to this recipient using a team-only API key"}],"status_code":400}\n, Exception: Status code 400. The following errors occured [\r\n {\r\n "error": "BadRequestError",\r\n "message": "Can’t send to this recipient using a team-only API key"\r\n }\r\n]"}

{"Status code 400. Error: {"errors":[{"error":"ValidationError","message":"phone_number Not enough digits"}],"status_code":400}\n, Exception: Status code 400. The following errors occured [\r\n {\r\n "error": "ValidationError",\r\n "message": "phone_number Not enough digits"\r\n }\r\n]"}

Change converts output from BaseClient.HandleHTTPErrors to return a standard JSON object of type 'NotifyHTTPErrorResponse' to allow Json Deserialisation.

{"status_code":"400", "errors": [{"error":"ValidationError","message":"phone_number Too many digits"}],"exception":null}

{"status_code":"400", "errors":[{"error":"ValidationError","message":"phone_number Not enough digits"}],"exception":null}

Related issue thread: #161

Checklist

  • I’ve used the pull request template
  • I’ve written unit tests for these changes
  • I’ve update the documentation (in DOCUMENATION.md and CHANGELOG.md)
  • I’ve bumped the version number (in src/GovukNotify/GovukNotify.csproj)

@symd-uk
Copy link

symd-uk commented Sep 8, 2023

Any way we can get this merged to master?

@IamAlecYoung
Copy link
Author

Any way we can get this merged to master?

I'm not 100% sure if I missed a step in requesting the merge,
@samuelhwilliams can you advise (Apologies if wrong person, I've seen you are quite active on this repo)

@symd-uk
Copy link

symd-uk commented Sep 8, 2023

Any way we can get this merged to master?

I'm not 100% sure if I missed a step in requesting the merge, @samuelhwilliams can you advise (Apologies if wrong person, I've seen you are quite active on this repo)

Thank you for responding. Just realised, does this change mean the documentation will have to change to?
https://docs.notifications.service.gov.uk/net.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants