Repository navigation
Conversation
… maximumResults An explicit null skips the GraphQL schema default, so unboxing these arguments to a primitive threw a NullPointerException. estimatedCalls on Quay and StopPlace now use false, and nearest uses 20, when the argument is null.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #8308 +/- ##
=============================================
+ Coverage 76.14% 76.17% +0.03%
- Complexity 24817 24823 +6
=============================================
Files 2658 2658
Lines 92948 92952 +4
Branches 9281 9281
=============================================
+ Hits 70772 70804 +32
+ Misses 19031 19001 -30
- Partials 3145 3147 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| @Test | ||
| void estimatedCallsAcceptsExplicitNullStartTime() { | ||
| var result = execute( | ||
| "{ stopPlace(id: \"F:S\") { estimatedCalls(startTime: null) { realtime } } }" |
There was a problem hiding this comment.
It's quite questionable that this should even be allowed, isn't it? Are you afraid of breaking a client if you reject it?
There was a problem hiding this comment.
This is in fact allowed yes, an I'm not changing that. Are you saying I should?
It has the same result as simply omitting the startTime:
{ stopPlace(id: \"F:S\") { estimatedCalls { realtime } } }Omitting is allowed and I think we default to now. If I disallowed it, we would probably break clients yes.
This all goes back to the philosophy I'm applying here that null can be used interchangeably with omitted. You may rightly question that. I'm doing it so it's consistent, not necessarily because I am a hard believer in it being the only right choice.
There was a problem hiding this comment.
I meant: should startTime: null as the input parameter not just throw? It's a terrible idea to explicitly supply null. What is the client trying to say with that?
There was a problem hiding this comment.
But I think you don't really have a choice as this would break clients.
There was a problem hiding this comment.
Aha, yeah I agree that looks dumb. But I've kind of just continued on an existing pattern which regrettably does allow a lot of nulls...
Examples my friend found:
- stopPlace(id: "…") { estimatedCalls(startTime: null) }
- quay(id: "…") { estimatedCalls(startTime: null) }
- stopPlaces(ids: null)
- quaysByRadius(latitude: 59.91, longitude: 10.75, radius: 500, authority: null)
- lines(name: null)
- datedServiceJourneys(lines: null, authorities: null)
- trip(walkSpeed: null)
If I were to change it, I would only want to do so consistently across the board, and then I feel we very likely would break some clients.
I haven't checked actual prod logs.
leonardehrenfried
left a comment
There was a problem hiding this comment.
The explanation is satisfactory.
Summary
When a client passes an explicit null for
includeCancelledTripsonestimatedCalls(quay or stop place), or formaximumResultsonnearest, the server throws aNullPointerExceptionand the user gets an internal error back. Both arguments have a default in the schema, but GraphQL only applies it when the argument is omitted, not when it is null.An explicit null is now handled like an omitted argument, same as in #8207.
Reproduction links: estimatedCalls, nearest
Issue
No issue. Small PR made from a production error.
Unit tests
Added for
estimatedCallson stop place and quay.AI also originally added a graphql test for the
nearestquery, but I deem this to be a bit to specific an edge case to warrant a whole new test. The second commit in this PR removes the test. I did verify manually that it fixes the original bug.Documentation
No public changes.