square / square/square-nodejs-sdk
Listing saved cards without passing in sortOrder causes `BAD_REQUEST` error
Open
Beginner friendly
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 116
- Forks
- 48
- Avg merge
- 2h 13m
- Merged PRs (30d)
- 1
Description
Library Version: 44.2.0
const cards = await client.cards.list({
customerId: squareCustomerId,
});
Response
Body: {
"errors": [
{
"category": "INVALID_REQUEST_ERROR",
"code": "INVALID_ENUM_VALUE",
"detail": "`` is not a valid enum value for `sort_order`.",
"field": "sort_order"
}
]
}
"rawResponse":{"headers":{},"redirected":false,"status":400,"statusText":"Bad Request","type":"basic","url":"https://connect.squareupsandbox.com/v2/cards?customer_id=<redacted>&sort_order="},
Expected behaviour
Not passing sortOrder should just return the default, presumably by just removing the &sort_order= query from the url when not provided.
Workaround
const cards = await client.cards.list({
customerId: squareCustomerId,
sortOrder: 'DESC',
});
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the cards.list entry point and trace how the optional sortOrder value is serialized into the request URL. Verify that omitting sortOrder no longer produces an empty sort_order query parameter, while an explicit value such as DESC remains supported and the list request succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100