fix(customers): default a Place location so signup with a place works - #293
Merged
Merged
Conversation
POST /v1/customers accepts an optional `place` object, and the documented payload in the Postman collection sends one. Creating it always failed: SQLSTATE[HY000]: General error: 1364 Field 'location' doesn't have a default value `places.location` is a NOT NULL POINT column with no database default, and the attribute allow-list in resolveCustomerPlace is address-only -- a caller cannot supply coordinates through this surface -- so Place::create was always called without one. Every documented signup that included a place returned a 500. Default it to Point(0, 0), the same placeholder the geocoding helpers already fall back to when an address cannot be resolved (Place::getGoogleAddressArray, Place::findExistingSharedPlace). The default sits in the base array of the array_merge, and `location` is not in the allow-list, so a caller can never override it. Verified against a live stack: the documented Create a Customer payload now returns 201 with the address resolved, and Place::create without a location still fails with 1364 -- confirming the default is what fixes it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #293 +/- ##
===========================================
Coverage 100.00% 100.00%
Complexity 9766 9766
===========================================
Files 521 521
Lines 37762 37763 +1
===========================================
+ Hits 37762 37763 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Open
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.
The bug
POST /v1/customersaccepts an optionalplaceobject, and the payload documented in the Postman collection sends one. Creating it always failed:places.locationis aPOINT NOT NULLcolumn with no database default, and the attribute allow-list inresolveCustomerPlaceis address-only — a caller cannot supply coordinates through this surface — soPlace::create()was always called without one.Every documented signup that included a place returned a 500.
The fix
Default it to
Point(0, 0)— the same placeholder the geocoding helpers already fall back to when an address cannot be resolved (Place::getGoogleAddressArray,Place::findExistingSharedPlace).The default sits in the base array of the
array_merge, andlocationis not in the allow-list, so a caller can never override it.Verified against a live stack
Create a Customerpayload → 500 with the error above.HOME - 123 MAIN STREET, KINGSTON, 00000, JAMAICA).Place::create()without a location still fails with1364, confirming the default is what fixes it — and the same request with noplacekey already returned 200 both before and after.Context
Found while making the
Customersfolder of the Postman collection pass (fleetbase/fleetbase#581) — this was the last blocker before all 16 requests returned 2xx.🤖 Generated with Claude Code