Skip to content

feat: require shape_id when a trip has continuous pickup or drop-off - #2173

Open
vssinghh wants to merge 1 commit into
MobilityData:masterfrom
vssinghh:feat/shape-id-required-for-continuous
Open

feat: require shape_id when a trip has continuous pickup or drop-off#2173
vssinghh wants to merge 1 commit into
MobilityData:masterfrom
vssinghh:feat/shape-id-required-for-continuous

Conversation

@vssinghh

Copy link
Copy Markdown
Contributor

Summary:

The spec makes trips.shape_id conditionally required: required if the trip has continuous pickup or drop-off behavior defined either in routes.txt or in stop_times.txt, optional otherwise. GtfsTripSchema already annotates shapeId as @ConditionallyRequired, but nothing enforced it.

Adds TripShapeIdConditionalValidator, which raises the existing missing_required_field notice (ERROR) on trips.shape_id when such a trip has no shape. This follows TransferStopIdsConditionalValidator and StopTimesGeographyIdPresenceValidator, which raise the generic notice under a conditional rather than defining a new notice type.

Two readings, both taken from the reference:

  • 1 and empty both mean no continuous stopping behavior, so only 0, 2 and 3 make shape_id required.
  • stop_times values override routes values, so the effective value for each stop time is the stop_times value where set, otherwise the route value.

Expected behavior:

Running the CLI on four variants of the Archive.zip from #1785:

routes.continuous_pickup stop_times.continuous_pickup result
1 (as attached) 1 (as attached) no notice
0 1 no notice, stop_times overrides
1 0 missing_required_field on trips.txt row 2
0 empty missing_required_field on trips.txt row 2
{"filename": "trips.txt", "csvRowNumber": 2, "fieldName": "shape_id"}

Worth noting that the archive attached to the issue has continuous_pickup=1 and continuous_drop_off=1 in every row of both files, so as attached it does not exercise the rule.

8 unit tests cover the four combinations plus the shape present, no continuous behavior, and no stop times cases.

Closes #1785

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with gradle test to make sure you didn't break anything
  • Add or update any needed documentation to the repo
  • Format the title like "feat: [new feature short description]". Title must follow the Conventional Commit Specification(https://www.conventionalcommits.org/en/v1.0.0/).
  • Linked all relevant issues
  • Include screenshot(s) showing how this pull request works and fixes the issue(s) (validator output above)

@welcome

welcome Bot commented Aug 19, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! You're awesome. We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of titles with semantic prefixes:

  • fix: Bug with ssl network connections + Java module permissions.
  • feat: Initial support for multiple @PrimaryKey annotations.
  • docs: update RELEASE.md with new process
    To get this PR to the finish line, please do the following:
  • Read our Contribution Guidelines
  • Follow Google Java style coding standards
  • Include tests when adding/changing behavior
  • Include screenshots

The spec makes trips.shape_id conditionally required: it is required if
the trip has continuous pickup or drop-off behavior defined in routes.txt
or in stop_times.txt. GtfsTripSchema already annotates shapeId as
@ConditionallyRequired, but nothing enforced it.

Adds TripShapeIdConditionalValidator, which emits the existing
MissingRequiredFieldNotice when such a trip has no shape_id. This follows
TransferStopIdsConditionalValidator and StopTimesGeographyIdPresenceValidator,
which raise the generic notice under a conditional rather than defining a
new notice type.

A value of 1 is treated like an empty value, since the reference defines
both as no continuous stopping behavior. Values in stop_times.txt override
those in routes.txt.

Closes MobilityData#1785
@vssinghh
vssinghh force-pushed the feat/shape-id-required-for-continuous branch from 71149cb to 58bcaef Compare August 22, 2026 04:36
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.

shape_id is required if the feed has continuous pickup/dropoff

1 participant