Skip to content

Passthrough NO_DATA schedule_relationship for stop_time_updates#467

Open
KTibow wants to merge 2 commits into
OneBusAway:mainfrom
KTibow:fix/passthrough-no-data
Open

Passthrough NO_DATA schedule_relationship for stop_time_updates#467
KTibow wants to merge 2 commits into
OneBusAway:mainfrom
KTibow:fix/passthrough-no-data

Conversation

@KTibow

@KTibow KTibow commented Jul 3, 2026

Copy link
Copy Markdown

When a GTFS-RT feed sets schedule_relationship: NO_DATA on a stop_time_update, it means no real-time timing is available and consumers should use the static GTFS schedule. OBA was treating NO_DATA the same as SCHEDULED, fabricating data.

Changes:

  • GtfsRealtimeTripLibrary (static path): Handle NO_DATA like SKIPPED but without arrival/departure times; skip time computation for NO_DATA
  • GtfsRealtimeTripLibrary (dynamic path): Add NO_DATA case to the switch; guard arrival/departure time reads against NO_DATA
  • TripStatusBeanServiceImpl: Passthrough schedule_relationship value directly instead of hardcoding SCHEDULED for non-skipped stops
  • TripUpdatesForAgencyAction: Write schedule_relationship from bean to the GTFS-RT StopTimeUpdate protobuf output

Disclosure: generated by DeepSeek V4 Pro with CI verification

Summary by CodeRabbit

  • Bug Fixes
    • Improved preservation of GTFS-RT stop schedule relationships when generating trip updates, including correct handling for stops with no available data.
    • Realtime prediction details are now aligned across realtime trip status and GTFS-RT outputs.
    • Stops marked as having no data no longer display incorrect predicted arrival/departure times.

When a GTFS-RT feed sets schedule_relationship: NO_DATA on a
stop_time_update, it means no real-time timing is available and
consumers should use the static GTFS schedule. OBA was treating
NO_DATA the same as SCHEDULED, fabricating predictions from the
arrival/departure time fields.

Changes:
- GtfsRealtimeTripLibrary (static path): Handle NO_DATA like SKIPPED
  but without arrival/departure times; skip time computation for NO_DATA
- GtfsRealtimeTripLibrary (dynamic path): Add NO_DATA case to the
  switch; guard arrival/departure time reads against NO_DATA
- TripStatusBeanServiceImpl: Passthrough schedule_relationship value
  directly instead of hardcoding SCHEDULED for non-skipped stops
- TripUpdatesForAgencyAction: Write schedule_relationship from bean
  to the GTFS-RT StopTimeUpdate protobuf output
@CLAassistant

CLAassistant commented Jul 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fbc948b6-efae-45dd-972a-b2ad3179d4e7

📥 Commits

Reviewing files that changed from the base of the PR and between f18c541 and e8c6e54.

📒 Files selected for processing (1)
  • onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/TripStatusBeanServiceImpl.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/TripStatusBeanServiceImpl.java

📝 Walkthrough

Walkthrough

GTFS-RT trip update processing now preserves NO_DATA schedule relationships through record creation, bean mapping, and StopTimeUpdate output. Predicted arrival and departure times are no longer computed for NO_DATA stops.

Changes

Schedule Relationship Propagation

Layer / File(s) Summary
Set NO_DATA schedule relationship and gate predicted times in trip update processing
onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/realtime/gtfs_realtime/GtfsRealtimeTripLibrary.java
applyDynamicTripUpdatesToRecord and applyTripUpdatesToRecord add explicit NO_DATA handling for TimepointPredictionRecord schedule relationship and skip predicted arrival/departure time computation for NO_DATA stops.
Propagate schedule relationship to bean and GTFS-RT output
onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/TripStatusBeanServiceImpl.java, onebusaway-api-webapp/src/main/java/org/onebusaway/api/actions/api/gtfs_realtime/TripUpdatesForAgencyAction.java
TripStatusBeanServiceImpl sets scheduleRealtionship directly from the record's enum value instead of isSkipped(); TripUpdatesForAgencyAction maps the timepoint prediction's schedule relationship onto the StopTimeUpdate.Builder when non-null.

Estimated code review effort: 2 (Simple) | ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: preserving NO_DATA schedule_relationship for stop_time_updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@KTibow

KTibow commented Jul 3, 2026

Copy link
Copy Markdown
Author

Once again, not signing the CLA because it needs to be updated to use a custom gist instead of the SAP default

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/TripStatusBeanServiceImpl.java (1)

372-387: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Guard scheduleRelationship before dereferencing it. AbstractOrbcadRecordSource still creates TimepointPredictionRecord instances without setting this field, so tpr.getScheduleRelationship().getValue() can throw here. Default it or add a null check before mapping.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/TripStatusBeanServiceImpl.java`
around lines 372 - 387, The timepoint prediction mapping in
TripStatusBeanServiceImpl dereferences scheduleRelationship without checking for
null, which can fail for TimepointPredictionRecord instances coming from
AbstractOrbcadRecordSource. Update the loop that builds TimepointPredictionBean
objects to guard tpr.getScheduleRelationship() before calling getValue(), and
either skip setting the field or supply a safe default when it is missing. Keep
the change localized to the timepointPredictions population block so the bean
assembly remains otherwise unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/TripStatusBeanServiceImpl.java`:
- Around line 372-387: The timepoint prediction mapping in
TripStatusBeanServiceImpl dereferences scheduleRelationship without checking for
null, which can fail for TimepointPredictionRecord instances coming from
AbstractOrbcadRecordSource. Update the loop that builds TimepointPredictionBean
objects to guard tpr.getScheduleRelationship() before calling getValue(), and
either skip setting the field or supply a safe default when it is missing. Keep
the change localized to the timepointPredictions population block so the bean
assembly remains otherwise unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 468626e0-c453-44fb-9a7d-e549b63a0d90

📥 Commits

Reviewing files that changed from the base of the PR and between 9bd105b and f18c541.

📒 Files selected for processing (3)
  • onebusaway-api-webapp/src/main/java/org/onebusaway/api/actions/api/gtfs_realtime/TripUpdatesForAgencyAction.java
  • onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/TripStatusBeanServiceImpl.java
  • onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/realtime/gtfs_realtime/GtfsRealtimeTripLibrary.java

@aaronbrethorst

Copy link
Copy Markdown
Member

@KTibow thanks for the head's up. there was some special casing for this repo in the CLA tool and I have removed it, so hopefully it defaults to the OBA org-wide CLA now.

AbstractOrbcadRecordSource creates TimepointPredictionRecord instances
without setting scheduleRelationship, so the direct passthrough in
TripStatusBeanServiceImpl would NPE. Add a null guard defaulting to
SCHEDULED, preserving the existing behavior for those records.
@KTibow

KTibow commented Jul 3, 2026

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

3 participants