Skip to content

API Incorrectly Rejects Future Date Queries #277

@ARCoder181105

Description

@ARCoder181105

Summary

The API currently blocks all queries for future dates (tomorrow and beyond), preventing users from planning trips in advance. This violates expected OneBusAway API behavior where future scheduling is a core feature.

Impact

  • ❌ Users cannot query schedules for tomorrow or any future date
  • ❌ Trip planning functionality is effectively broken
  • ❌ Non-compliant with standard OneBusAway API expectations

Root Cause

File: internal/utils/api.go
Lines: 85-91
Function: ParseTimeParameter

The function contains validation logic that explicitly rejects any date after today's midnight.

Reproduction

# Query for tomorrow's schedule - this will fail
curl "http://localhost:4000/api/where/schedule-for-stop/{id}?key=test&date=2026-02-02"

# Returns 400 error: "Invalid field value for field \"time\"."

Proposed Fix

Remove lines 85-91 from internal/utils/api.go that check if parsedTimeMidnight.After(todayMidnight) and return an error.

The function should accept future dates and let the GTFS data availability determine what can be returned.

Test Updates Required

File: internal/utils/api_test.go

  1. Update the test case named "Future date (should fail)" to expect success instead of failure
  2. Add a new test case TestParseTimeParameter_FutureDate to verify future dates are accepted and prevent regression

Verification

make test
go test ./internal/utils -run TestParseTimeParameter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions