Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[DDW-318] Remove pretty-encoding for JSONValidationError #3619

Merged
merged 2 commits into from
Sep 18, 2018

Conversation

KtorZ
Copy link
Contributor

@KtorZ KtorZ commented Sep 18, 2018

Description

This is inherited from the old times but is actually wrong.
Pretty encoding is good for human to look at, but when it comes
to parsers, newlines aren't much appreciated (e.g. Daedalus parser).

Curious that this was never caught before, probably because
JSONValidationError weren't really caught by Daedalus. Now some of
them are so we better have well-formed responses :)

Linked issue

[DDW-318]

Type of change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🛠 New feature (non-breaking change which adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
  • 🏭 Refactoring that does not change existing functionality but does improve things like code readability, structure etc
  • 🔨 New or improved tests for existing code
  • ⛑ git-flow chore (backport, hotfix, etc)

Developer checklist

  • I have read the style guide document, and my code follows the code style of this project.
  • If my code deals with exceptions, it follows the guidelines.
  • I have updated any documentation accordingly, if needed. Documentation changes can be reflected in opening a PR on cardanodocs.com, amending the inline Haddock comments, any relevant README file or one of the document listed in the docs directory.
  • CHANGELOG entry has been added and is linked to the correct PR on GitHub.

Testing checklist

  • [ ] I have added tests to cover my changes.
  • [z] All new and existing tests passed.

QA Steps

With cURL, an invalid request to trigger a JSONValidationFailed (e.g. using the example mnemonic) returns a response that is correctly encoded.

> POST /api/v1/wallets HTTP/1.1
> Host: localhost:8090
> User-Agent: curl/7.47.0
> Accept: */*
> Content-Length: 224

< HTTP/1.1 400 Bad Request
< Transfer-Encoding: chunked
< Date: Tue, 18 Sep 2018 05:08:30 GMT
< Server: Warp/3.2.22

{"status":"error","diagnostic":{"validationError":"Error in $.backupPhrase: Forbidden Mnemonic: an example Mnemonic has been submitted. Please generate a fresh and private Mnemonic from a trusted source"},"message":"JSONValidationFailed"}

Screenshots (if available)

This is inherited from the old times but is actually wrong.
Pretty encoding is good for human to look at, but when it comes
to parsers, newlines aren't much appreciated (e.g. Daedalus parser).

Curious that this was never caught before, probably because
JSONValidationError weren't really caught by Daedalus. Now some of
them are so we better have well-formed responses :)
@KtorZ KtorZ merged commit 71fca29 into develop Sep 18, 2018
@KtorZ KtorZ deleted the KtorZ/DDW-318/fix-pretty-encoding branch September 18, 2018 08:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants