Skip to content

500 error for the Mouser provider #1179

@wendefeuer

Description

@wendefeuer

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

  1. 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)"

  2. 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'."}}

  3. 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions