fix: omit schedule field from trip-details response when nil#1073
fix: omit schedule field from trip-details response when nil#10733rabiii wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThe ChangesTripDetails schedule omitempty fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/models/trip_details.go (1)
7-7: ⚡ Quick winConsider adding an inline comment for consistency and documentation.
Line 6 includes an inline comment explaining why
omitemptyis intentional for theFrequencyfield. Since this change addresses a specific compliance requirement (OpenOneBusAway wiki spec), adding a similar comment would improve consistency and document the intentional behavior.📝 Suggested inline comment
- Schedule *Schedule `json:"schedule,omitempty"` + Schedule *Schedule `json:"schedule,omitempty"` // omitempty intentional: trip-details callers expect the field absent when includeSchedule=false per OpenOneBusAway wiki spec🤖 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 `@internal/models/trip_details.go` at line 7, The Schedule field struct tag on line 7 lacks an inline comment explaining the intentional use of omitempty, while the Frequency field on line 6 includes such a comment for consistency and documentation. Add an inline comment to the Schedule field that explains the intentional omitempty behavior related to the OpenOneBusAway wiki spec compliance requirement, following the same comment pattern and style used for the Frequency field on line 6.
🤖 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.
Inline comments:
In `@internal/models/trip_details.go`:
- Line 7: The typecheck errors indicate that the types Frequency, Schedule,
ModelTime, Location, and TripStatus are not defined or visible in the current
context, even though they should exist in the internal/models package. Check
whether these types are defined in other Go files within the internal/models
directory; if they are, verify that all relevant files are being compiled
together and there are no circular dependencies or build constraint issues
preventing them from being recognized. If these type definitions are missing
entirely, you must create them in the appropriate files within internal/models.
Review all references to these undefined types throughout the file (particularly
in the TripDetails struct fields) and ensure the type definitions are properly
exported (capitalized names) and accessible to the compiler.
---
Nitpick comments:
In `@internal/models/trip_details.go`:
- Line 7: The Schedule field struct tag on line 7 lacks an inline comment
explaining the intentional use of omitempty, while the Frequency field on line 6
includes such a comment for consistency and documentation. Add an inline comment
to the Schedule field that explains the intentional omitempty behavior related
to the OpenOneBusAway wiki spec compliance requirement, following the same
comment pattern and style used for the Frequency field on line 6.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 368dccf1-0317-4203-9e3d-ac678e8af669
📒 Files selected for processing (1)
internal/models/trip_details.go



Description
This PR addresses to ensure strict compliance with the wiki spec regarding the
schedulefield in thetrip-detailsendpoint.The spec explicitly states: "The schedule key is absent from the entry entirely" when
includeSchedule=false. Previously, the field lacked theomitemptytag, causing the JSON encoder to emit"schedule": nullwhen the schedule pointer wasnil.Changes Included:
omitemptytag to theSchedulefield within theTripDetailsmodel (internal/models/trip_details.go). This ensures the key is completely dropped from the JSON payload when the schedule is not requested, matching the expected contract behavior.Fixes: #1058
Summary by CodeRabbit