karrioapi / karrio

Programmable Shipping API (self-hosted)
https://karrio.io
Apache License 2.0
407 stars 82 forks source link

When there are multiple accounts of the same type, the proxy void label api will result in an error. #590

Closed mliz1984 closed 1 month ago

mliz1984 commented 1 month ago

Describe the bug When a user registers multiple accounts of the same type (e.g., multiple UPS accounts) within the system, using the Proxy Void Label API is likely to result in errors.

Because the Proxy Void Label API uses the carrier name to search for user accounts, when there are multiple accounts of the same type, the API only selects the first one. This causes an insufficient permissions error when attempting to void the label for other accounts.

To Reproduce 1 Set up multiple accounts of the same type, such as multiple UPS accounts, within a single user. 2 Generate a label using each account. 3 Use the Proxy Void Label API to attempt to void these label. 4 You will find that the API always uses a single fixed account to void all the labels, causing most void requests to fail.

Expected behavior All labels should be successfully voided.

Additional context There are two possible solutions:

Record All Accounts:

1 Keep a record of all accounts used each time a label is generated. When voiding a label, use the corresponding account from the record.

2 Specify carrier_id: Since the proxy does not keep records in the database, if the first method is not feasible, modify the API to allow the input of a carrier_id to specify the account. These solutions should help ensure the correct account is used when voiding a label.

danh91 commented 1 month ago

Thanks @mliz1984 for the detailed issue.

You are correct and since the proxy does not keep records in the database I would also lean toward the second solution.

mliz1984 commented 1 month ago

@danh91 Tried 2024.6-rc7 .the request data is {"shipment_identifier": "1Z64YA9020127424150","carrier_id":"UPS-GTA"} but return { "messages": [ { "carrier_id": "UPS-QC", "carrier_name": "ups", "code": "190100", "message": "Invalid or Missing ShipmentIdentificationNumber." } ] } looks like the parameter doesn't work