Skip to content

Conversation

@Ansh-Dev-Nagar
Copy link
Contributor

Fix EasyPost Service Collisions with Carrier-Aware Resolution

Summary

This PR fixes incorrect EasyPost service resolution caused by service name collisions across carriers by introducing a carrier-aware service lookup. Services are now resolved using both carrier + service name, ensuring the correct service codes are returned.

Problem

EasyPost exposes services from multiple carriers that share the same names (e.g. Priority, Ground).
Service resolution relied only on the service name, which—due to Python enum aliasing—caused services from different carriers to incorrectly map to the same enum.

This resulted in wrong service codes being used, such as:

  • USPS Priority resolving to a Canada Post service
  • UPSDAP Ground resolving to a Canpar service

Carrier name variations returned by the EasyPost API also caused carrier lookups to fail.

Solution

  • Normalize carrier names to handle EasyPost API variations (e.g. UPSDAPUPS)
  • Resolve services using carrier-qualified keys (easypost_{carrier}_{service})
  • Bypass Python enum aliasing by checking for qualified service attributes
  • Fall back to existing behavior to maintain backward compatibility
  • Add safety checks for null or unknown values

Testing

  • All existing tests pass with no regressions
  • Added coverage for service collision scenarios
  • Verified correct resolution for USPS, UPS, Canada Post, and Canpar services

Impact

  • Correct service codes returned for all carriers
  • Eliminates cross-carrier service collisions
  • Backward-compatible bug fix with no breaking changes

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.

2 participants