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

Behavior when leading "/" is ommitted? #176

Closed
sttawm opened this issue Jul 22, 2020 · 4 comments · Fixed by #177
Closed

Behavior when leading "/" is ommitted? #176

sttawm opened this issue Jul 22, 2020 · 4 comments · Fixed by #177
Assignees
Labels
Milestone

Comments

@sttawm
Copy link

sttawm commented Jul 22, 2020

What should the behavior be if the leading "/" in the path is omitted?

I get a pretty gnarly error in that case.

Sorry it's not a full example, I can do that if that'll be helpful. Here's what I have for now:

        "java.util.NoSuchElementException: JsError.get",
        "at play.api.libs.json.JsError.get(JsResult.scala:53)",
        "at play.api.libs.json.JsError.get(JsResult.scala:52)",
        "at diffson.playJson.DiffsonProtocol$.$anonfun$OperationFormat$1(DiffsonProtocol.scala:78)",
        "at play.api.libs.json.Reads$$anon$6.reads(Reads.scala:222)",
        "at play.api.libs.json.Format$$anon$6.reads(Format.scala:62)",
        "at play.api.libs.json.LowPriorityDefaultReads$$anon$8.$anonfun$reads$1(Reads.scala:268)",

I'm using a JsonPatch[JsValue] (play)

@satabin satabin self-assigned this Jul 22, 2020
@satabin satabin added the bug label Jul 22, 2020
@satabin
Copy link
Member

satabin commented Jul 22, 2020

Hello, this is indeed not really helpful. On the top of my head, I'd say it should be a syntax error when parsing the pointer, so something is broken in the error handling here in diffson, I will fix this. Thanks for reporting.

@satabin satabin added this to the 4.0.3 milestone Jul 22, 2020
@satabin
Copy link
Member

satabin commented Jul 22, 2020

After some more investigation, it appears it is a problem in the Play! JSON deserialization. The actual exception is swallowed in case of an error. I will fix this, but you will still get an exception (namely a PointerException) however, with a more explanatory message: "JSON pointer must start with a '/'", as per RFC-6901.

@satabin
Copy link
Member

satabin commented Jul 22, 2020

Behavior has been fix and I just released 4.0.3 with the fix. You should now get an exception that gives you a useful message.

@sttawm
Copy link
Author

sttawm commented Jul 22, 2020

Wonderful! Thanks for the quick fix

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

Successfully merging a pull request may close this issue.

2 participants