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.
feat: client/server ID split — Phase 1 (DB shim + API) #2447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
feat: client/server ID split — Phase 1 (DB shim + API) #2447
Changes from all commits
74590de56645ef372b36274ab574847fca0e098fd1bb071111852074File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard for
!databefore parsing API responses.In Line 17/27/45 flows, the code checks
errorbut still usesdata/resultwithout null checks. Adderror || !data(and!result) guards beforeTripSchema.parse(...)to avoid undefined payload crashes.Suggested diff
const listTrips = async () => { const { data, error } = await apiClient.trips.get({ query: { includePublic: 0 } }); - if (error) throw new Error(`Failed to list trips: ${error.value}`); + if (error || !data) throw new Error(`Failed to list trips: ${error?.value ?? 'empty response'}`); return TripSchema.array().parse(data) as unknown as TripInStore[]; }; @@ const { data, error } = await apiClient.trips.post({ @@ }); - if (error) throw new Error(`Failed to create trip: ${error.value}`); + if (error || !data) throw new Error(`Failed to create trip: ${error?.value ?? 'empty response'}`); return TripSchema.parse(data) as unknown as TripInStore; }; @@ const { data: result, error } = await apiClient.trips({ tripId: String(id) }).put({ @@ }); - if (error) throw new Error(`Failed to update trip: ${error.value}`); + if (error || !result) throw new Error(`Failed to update trip: ${error?.value ?? 'empty response'}`); return TripSchema.parse(result) as unknown as TripInStore; };As per coding guidelines, "Check for
error || !databefore using responsedatafrom the API client — responses are{ data, error, status }".Also applies to: 39-42, 55-58
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: PackRat-AI/PackRat
Length of output: 3372
🏁 Script executed:
Repository: PackRat-AI/PackRat
Length of output: 4750
Replace
as unknown as TripInStorewith an explicit mapper function.The schema parse returns objects with
clientUuidand nullable fields that don't exist inTripInStore. The double-cast silently dropsclientUuidand masks nullability mismatches (e.g.,descriptioncan be null in schema but not in the store type). Create a small normalizer to make this transformation explicit:Then use it at lines 20, 41, and 57 instead of the double-cast. This improves type safety and makes the implicit drift auditable.
🤖 Prompt for AI Agents
Uh oh!
There was an error while loading. Please reload this page.