Skip to content

fix(usps): declare usps_rate_indicator option and price_type connection config#1121

Open
zggit wants to merge 1 commit into
karrioapi:mainfrom
zggit:fix/usps-contract-rates
Open

fix(usps): declare usps_rate_indicator option and price_type connection config#1121
zggit wants to merge 1 commit into
karrioapi:mainfrom
zggit:fix/usps-contract-rates

Conversation

@zggit

@zggit zggit commented Jun 9, 2026

Copy link
Copy Markdown

Summary

USPS contract (NSA) pricing is unreachable through the connector. usps_rate_indicator is consumed in the label request and price_type is consumed in the rate request, but neither is declared in its enum, so both are silently dropped by the options filter. Labels always ship with the hardcoded DR rate indicator, which makes USPS answer "Contract rate not found for request. Published rate returned." and bill published rates instead of the account's contract rates.

Changes

File What changed
providers/usps/units.py Declare usps_rate_indicator in ShippingOption
providers/usps/utils.py Declare price_type in ConnectionConfig (read by rate.py)
providers/usps/shipment/create.py Default label rateIndicator DRSP (single piece)
tests/usps/test_shipment.py Request fixture updated for the new default

Verification

Verified against the live USPS API with an EPS account holding contract rates: quotes (price_type: CONTRACT connection config) and label postage both return the contract price. All 34 USPS connector tests pass.

…on config

- usps_rate_indicator is read in the label request but was never declared
  in ShippingOption, so shipping_options_initializer's items_filter
  silently dropped it and labels always used the hardcoded DR indicator.
- price_type is read from connection_config in rate.py but was never
  declared in ConnectionConfig, so config {"price_type": "CONTRACT"} was
  silently dropped and rate requests always fell back to RETAIL.
- Default label rateIndicator changed DR -> SP (single piece). Contract
  (NSA) pricing typically covers SP, and the DR default caused USPS to
  answer 'Contract rate not found for request. Published rate returned.'
  and bill published rates instead of the account's contract rates.
@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the karrio Team on Vercel.

A member of the Team first needs to authorize it.

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