refactor(gtfs): replace direct stderr printing with structured logging#301
Open
3rabiii wants to merge 4 commits intoOneBusAway:mainfrom
Open
refactor(gtfs): replace direct stderr printing with structured logging#3013rabiii wants to merge 4 commits intoOneBusAway:mainfrom
3rabiii wants to merge 4 commits intoOneBusAway:mainfrom
Conversation
aaronbrethorst
requested changes
Feb 6, 2026
Member
aaronbrethorst
left a comment
There was a problem hiding this comment.
Hey Adel, thanks for tackling this logging cleanup — replacing raw stderr writes with structured logging is exactly the kind of improvement that pays off in observability. The structured context fields (trip_id, block_id) are a nice touch. Before we can merge this, I need you to fix one issue:
Critical
- Nil error panic in
LogError(internal/gtfs/gtfs_manager.go:351-353): The condition on line 351 iserr != nil || !requestedTrip.BlockID.Valid, which meanserrcan benilwhen the block ID is simply invalid.logging.LogErrorunconditionally callserr.Error()(structured_logging.go:30), so passing anilerror will cause a nil pointer dereference panic. The originalfmt.Fprintfhandled this gracefully because%vprints<nil>for nil values. You'll need to either guard againstnilbefore callingLogError, or split the condition into two separate checks with different log messages (which would also be more informative — "trip not found" vs. "trip has no block ID" are different situations worth distinguishing).
Thanks again, and I look forward to merging this change.
Contributor
Author
|
Thanks for the critical catch! I've addressed the potential nil pointer panic in
@aaronbrethorst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
This PR refactors
GetVehicleForTripingtfs_manager.goto use the project's structured logger (slog/logging.LogError) instead of writing directly toos.stderrusingfmt.Fprintf.Changes
fmt.Fprintf(os.Stderr, ...)withlogging.LogError.trip_id,block_id) to the logs for better observability.osimport.@aaronbrethorst
fixes : #300