Skip to content

Fix polymorphic customer type serialization#52

Open
roncodes wants to merge 1 commit intomainfrom
feature/fix-polymorphic-customer-serialization
Open

Fix polymorphic customer type serialization#52
roncodes wants to merge 1 commit intomainfrom
feature/fix-polymorphic-customer-serialization

Conversation

@roncodes
Copy link
Copy Markdown
Member

@roncodes roncodes commented May 6, 2026

Summary

Fixes order and waypoint polymorphic customer serialization so selected customer records serialize with their concrete subtype, contact or vendor, instead of the abstract Ember relationship model, customer.

A recent serializer change removed the fallback to the related record's own polymorphic type attribute. When an order was created with a selected customer model, the order serializer fell back to belongsTo.modelName, producing customer_type fleet-ops:customer. FleetOps does not have a Fleetbase FleetOps Models Customer model, so Laravel later failed resolving the order customer morph relation while building the created webhook payload.

Changes

  • Restores the related-record subtype fallback in addon/serializers/order.js.
  • Restores the same fallback in addon/serializers/waypoint.js.
  • Keeps the existing abstract subtype stripping behavior for values such as customer-contact, customer-vendor, and facilitator-vendor.
  • Moves waypoint type resolution behind the null relationship check so null customer relationships still serialize as customer_type null without dereferencing belongsTo.modelName too early.

Why

For customer selector results, the Ember model can be the abstract customer model while the payload includes the concrete subtype in customer_type, for example contact or vendor. The serializer needs to prefer that concrete subtype when present. Otherwise the backend receives fleet-ops:customer, converts it to Fleetbase FleetOps Models Customer, and crashes because the concrete FleetOps model is actually Contact or Vendor.

Verification

  • ./node_modules/.bin/prettier --check addon/serializers/order.js addon/serializers/waypoint.js
  • ./node_modules/.bin/eslint --no-cache addon/serializers/order.js addon/serializers/waypoint.js
  • git diff --check -- addon/serializers/order.js addon/serializers/waypoint.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant