Part-DB
Version: 2.4.0
Hi Part-DB team,
I can reproduce a 500 error for the Mouser provider in “Create part from information source”.
From the Part-DB container logs, Part-DB calls:
POST https://api.mouser.com/api/v2/search/keyword?apiKey=
Mouser responds with HTTP 200 but with an error JSON payload:
{"Errors":[{"Code":"Invalid","Message":"Invalid unique identifier.","PropertyName":"API Key"}],"SearchResults":null}
Part-DB then throws a RuntimeException and returns 500:
RuntimeException: "Unknown response format: {"Errors":[...],"SearchResults":null}"
at MouserProvider.php:232 (responseToDTOArray)
Log excerpt (sanitized):
Reproduction / verification from the same container network
-
Extract the last Mouser URL from logs:
URL="$(sudo docker logs --tail 5000 partdb 2>&1 | grep -oE 'https?://api.mouser.com[^\" ]+' | tail -n 1)"
-
Confirm the endpoint is POST-only:
sudo docker run --rm --network container:partdb curlimages/curl:8.5.0 -sS -I "$URL"
-> HTTP 405
sudo docker run --rm --network container:partdb curlimages/curl:8.5.0 -sS "$URL"
-> {"Error":{"Code":"UnsupportedApiVersion","Message":"... does not support HTTP method 'GET'."}}
-
POST to the same endpoint yields HTTP 200 with an error JSON (when the API key/request is not accepted):
PAYLOAD='<(ideally the exact JSON payload that Part-DB sends)>'
sudo docker run --rm --network container:partdb curlimages/curl:8.5.0
-sS -X POST -H "Content-Type: application/json" --data "$PAYLOAD" "$URL" | head -c 800
Expected behavior
- If Mouser returns Errors[] (even with HTTP 200), Part-DB should surface a provider-level error message (e.g. invalid API key / invalid request) and not crash with a 500 “unknown response format”.
Thanks!
Part-DB
Version: 2.4.0
Hi Part-DB team,
I can reproduce a 500 error for the Mouser provider in “Create part from information source”.
From the Part-DB container logs, Part-DB calls:
POST https://api.mouser.com/api/v2/search/keyword?apiKey=
Mouser responds with HTTP 200 but with an error JSON payload:
{"Errors":[{"Code":"Invalid","Message":"Invalid unique identifier.","PropertyName":"API Key"}],"SearchResults":null}
Part-DB then throws a RuntimeException and returns 500:
RuntimeException: "Unknown response format: {"Errors":[...],"SearchResults":null}"
at MouserProvider.php:232 (responseToDTOArray)
Log excerpt (sanitized):
Reproduction / verification from the same container network
Extract the last Mouser URL from logs:
URL="$(sudo docker logs --tail 5000 partdb 2>&1 | grep -oE 'https?://api.mouser.com[^\" ]+' | tail -n 1)"
Confirm the endpoint is POST-only:
sudo docker run --rm --network container:partdb curlimages/curl:8.5.0 -sS -I "$URL"
-> HTTP 405
sudo docker run --rm --network container:partdb curlimages/curl:8.5.0 -sS "$URL"
-> {"Error":{"Code":"UnsupportedApiVersion","Message":"... does not support HTTP method 'GET'."}}
POST to the same endpoint yields HTTP 200 with an error JSON (when the API key/request is not accepted):
PAYLOAD='<(ideally the exact JSON payload that Part-DB sends)>'
sudo docker run --rm --network container:partdb curlimages/curl:8.5.0
-sS -X POST -H "Content-Type: application/json" --data "$PAYLOAD" "$URL" | head -c 800
Expected behavior
Thanks!