Skip to content

Fix exception on null-valued includeCancelledTrips in Transmodel - #8308

Merged
sigtot merged 2 commits into
opentripplanner:dev-2.xfrom
entur:warning/transmodel-null-argument-defaults
Dec 4, 2026
Merged

sigtot merged 2 commits into
opentripplanner:dev-2.xfrom
entur:warning/transmodel-null-argument-defaults

Conversation

@sigtot

@sigtot sigtot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When a client passes an explicit null for includeCancelledTrips on estimatedCalls (quay or stop place), or for maximumResults on nearest, the server throws a NullPointerException and 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 estimatedCalls on stop place and quay.

AI also originally added a graphql test for the nearest query, 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.

… 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.
@sigtot
sigtot requested a review from a team as a code owner December 3, 2026 13:21
@sigtot sigtot added the !Bug Apply to issues describing a bug and PRs witch fixes it. label Dec 3, 2026
@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.17%. Comparing base (51386ec) to head (7ef2107).
⚠️ Report is 1 commits behind head on dev-2.x.

Files with missing lines Patch % Lines
...pis/transmodel/TransmodelGraphQLSchemaFactory.java 25.00% 3 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sigtot sigtot changed the title Warning/transmodel null argument defaults Fix exception on null-valued includeCancelledTrips in Transmodel Dec 3, 2026
@t2gran t2gran added this to the 2.11 (next release) milestone Dec 3, 2026
@Test
void estimatedCallsAcceptsExplicitNullStartTime() {
var result = execute(
"{ stopPlace(id: \"F:S\") { estimatedCalls(startTime: null) { realtime } } }"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's quite questionable that this should even be allowed, isn't it? Are you afraid of breaking a client if you reject it?

@sigtot sigtot Dec 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I think you don't really have a choice as this would break clients.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 leonardehrenfried left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explanation is satisfactory.

@sigtot
sigtot added this pull request to the merge queue Dec 4, 2026
Merged via the queue into opentripplanner:dev-2.x with commit d2091ed Dec 4, 2026
7 checks passed
@sigtot
sigtot deleted the warning/transmodel-null-argument-defaults branch December 4, 2026 15:16
t2gran pushed a commit that referenced this pull request Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

!Bug Apply to issues describing a bug and PRs witch fixes it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants