Skip to content

Label Generation for (non-standard) Packages #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
batonac opened this issue Nov 16, 2022 · 7 comments
Open

Label Generation for (non-standard) Packages #67

batonac opened this issue Nov 16, 2022 · 7 comments

Comments

@batonac
Copy link

batonac commented Nov 16, 2022

I'm getting "Object reference not set to an instance of an object." and "Invalid packageCode" when trying to generate labels:
Label Errors

How can I diagnose what's going on here?

@agritheory
Copy link

Can you share the traceback?

@batonac
Copy link
Author

batonac commented Nov 17, 2022

Please pardon my ignorance, but I'm not even sure how to get that. I am accustomed to having a "copy to clipboard" button in frappe, and I can't find anything in the frappe error logs.

@agritheory
Copy link

Try the browser console for a traceback first, if there isn't one there, look in ~/frappe-bench/logs/web.error.log

@batonac
Copy link
Author

batonac commented Nov 17, 2022

Oh, yes, I "knew" that... here's the traceback from both errors:

/api/method/shipstation_integration.shipping.create_shipping_label:1          Failed to load resource: the server responded with a status of 417 ()
desk.min.js?ver=1668612155.0:1 Traceback (most recent call last):
  File "apps/shipstation_integration/shipstation_integration/shipping.py", line 108, in _create_shipping_label
    shipment = client.create_label_for_order(shipstation_order)
  File "env/lib/python3.8/site-packages/shipstation/api.py", line 86, in create_label_for_order
    r = self.post(endpoint="/orders/createlabelfororder", data=label_data)
  File "env/lib/python3.8/site-packages/shipstation/http.py", line 56, in post
    r.raise_for_status()
  File "env/lib/python3.8/site-packages/httpx/_models.py", line 844, in raise_for_status
    raise HTTPError(message, response=self)
httpx._exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://ssapi.shipstation.com/orders/createlabelfororder
For more information check: https://httpstatuses.com/500

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 69, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 38, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 76, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1457, in call
    return fn(*args, **newargs)
  File "apps/shipstation_integration/shipstation_integration/shipping.py", line 44, in create_shipping_label
    _create_shipping_label(doc, values, user=frappe.session.user)
  File "apps/shipstation_integration/shipstation_integration/shipping.py", line 111, in _create_shipping_label
    process_error(response)
  File "apps/shipstation_integration/shipstation_integration/shipping.py", line 156, in process_error
    frappe.throw(_(message))
  File "apps/frappe/frappe/__init__.py", line 504, in throw
    msgprint(
  File "apps/frappe/frappe/__init__.py", line 479, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 434, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.ValidationError: Object reference not set to an instance of an object.

jquery.min.js:4          POST https://erp.littlecocalico.com/api/method/shipstation_integration.shipping.create_shipping_label 417
send @ jquery.min.js:4
ajax @ jquery.min.js:4
frappe.request.call @ desk.min.js?ver=1668612155.0:1
frappe.call @ desk.min.js?ver=1668612155.0:1
shipping.create_shipping_label @ shipstation_integration.min.js?ver=1668612155.0:1
primary_action @ shipstation_integration.min.js?ver=1668612155.0:1
(anonymous) @ desk.min.js?ver=1668612155.0:1
dispatch @ jquery.min.js:3
r.handle @ jquery.min.js:3
desk.min.js?ver=1668612155.0:1 Traceback (most recent call last):
  File "apps/shipstation_integration/shipstation_integration/shipping.py", line 108, in _create_shipping_label
    shipment = client.create_label_for_order(shipstation_order)
  File "env/lib/python3.8/site-packages/shipstation/api.py", line 86, in create_label_for_order
    r = self.post(endpoint="/orders/createlabelfororder", data=label_data)
  File "env/lib/python3.8/site-packages/shipstation/http.py", line 56, in post
    r.raise_for_status()
  File "env/lib/python3.8/site-packages/httpx/_models.py", line 844, in raise_for_status
    raise HTTPError(message, response=self)
httpx._exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://ssapi.shipstation.com/orders/createlabelfororder
For more information check: https://httpstatuses.com/500

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 69, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 38, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 76, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1457, in call
    return fn(*args, **newargs)
  File "apps/shipstation_integration/shipstation_integration/shipping.py", line 44, in create_shipping_label
    _create_shipping_label(doc, values, user=frappe.session.user)
  File "apps/shipstation_integration/shipstation_integration/shipping.py", line 111, in _create_shipping_label
    process_error(response)
  File "apps/shipstation_integration/shipstation_integration/shipping.py", line 156, in process_error
    frappe.throw(_(message))
  File "apps/frappe/frappe/__init__.py", line 504, in throw
    msgprint(
  File "apps/frappe/frappe/__init__.py", line 479, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 434, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.ValidationError: Invalid packageCode


@agritheory
Copy link

When using the 'Package' package, I think it's expecting dimensional information, for which an input is not provided in the UI.
We need to attach a ShipstationContainer model to the Order model to defeat this.
https://github.com/agritheory/shipstation-client/blob/master/shipstation/models.py#L239

@Alchez
Copy link
Contributor

Alchez commented Nov 18, 2022

@agritheory @batonac

Looking at the docs, it seems like packageCode is no longer a relevant parameter? It still shows up in their example request, but not in the actual parameter list.

Either way, it seems like dimensions is the only package detail you can pass, and it's optional. So I'm not sure exactly why it's failing here.

Side-note: @agritheory, it seems like the client is reporting 500 errors for both of these, even though the invalid packageCode error seems like it's 400 at best. Are these being reported incorrectly from Shipstation, or is this something going on with the httpx module, you think?

@batonac batonac changed the title Label Generation Errors Label Generation for (non-standard) Packages Dec 9, 2022
@batonac
Copy link
Author

batonac commented Dec 9, 2022

In my client's scenario, we have several box sizes he uses that I'd like to make available in a drop-down link. Is there a pre-existing doctype available for this (I'm not seeing any), or would it make sense to build this into this integration, perhaps as a dedicated "Shipstation Custom Package" doctype?

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

No branches or pull requests

3 participants