Skip to content
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

Error 500 when filtering by codes in listCoupons #94

Closed
hookdump opened this issue Dec 13, 2024 · 2 comments
Closed

Error 500 when filtering by codes in listCoupons #94

hookdump opened this issue Dec 13, 2024 · 2 comments

Comments

@hookdump
Copy link

Hey all! I have already opened a zendesk ticket for this, so I apologize for the duplication, but I figured it might be more efficient to post it here.

If I call the listCoupons function without any filters, it works perfectly, and I'm able to list all coupons successfully. e.g.

listCoupons({
 currencyPrices: true,
});

However, if I input a codes filter, I get a 500 error. e.g.

listCoupons({
 filter: {
 codes: ['5OFFzzz'],
 },
 currencyPrices: true,
});

I get...

ApiError: Response status code was not ok: 500.
    at new ApiError (/home/ig/Work/churnkey/api/node_modules/@apimatic/core/lib/errors/apiError.js:16:28)
    at /home/ig/Work/churnkey/api/node_modules/@apimatic/core/lib/http/requestBuilder.js:352:23
    at DefaultRequestBuilder.<anonymous> (/home/ig/Work/churnkey/api/node_modules/@apimatic/core/lib/http/requestBuilder.js:186:50)
    at step (/home/ig/Work/churnkey/api/node_modules/tslib/tslib.js:196:27)
    at Object.next (/home/ig/Work/churnkey/api/node_modules/tslib/tslib.js:177:57)
    at fulfilled (/home/ig/Work/churnkey/api/node_modules/tslib/tslib.js:167:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  request: {
    method: 'GET',
    url: 'https://churnkey.chargify.com/coupons.json?filter%5Bcodes%5D%5B0%5D=5OFFzzz&currency_prices=true',
    headers: { 'user-agent': 'AB SDK TypeScript:5.2.0 on OS linux' },
    auth: {
▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
      password: 'X'
    }
  },
  statusCode: 500,
  headers: {
    'cache-control': 'private, no-store',
    'content-type': 'application/json',
    date: 'Thu, 12 Dec 2024 16:00:20 GMT',
    'referrer-policy': 'strict-origin-when-cross-origin',
    server: 'nginx + Phusion Passenger(R)',
    status: '500 Internal Server Error',
    'x-content-type-options': 'nosniff',
    'x-download-options': 'noopen',
    'x-frame-options': 'SAMEORIGIN',
    'x-permitted-cross-domain-policies': 'none',
    'x-powered-by': 'Phusion Passenger(R) Enterprise',
    'x-request-id': '11ff5b33-a822-450c-8821-d064ae0025bd',
    'x-runtime': '0.035440',
    'x-xss-protection': '1; mode=block',
    'content-length': '0',
    connection: 'keep-alive'
  },
  body: ''
}

Looking at the URL in the error message, I noticed it's urlencoded:
https://churnkey.chargify.com/coupons.json?filter%5Bcodes%5D%5B0%5D=5OFFzzz&currency_prices=true

So I tried to directly call the API, but decoded, and it works properly:
https://churnkey.chargify.com/coupons.json?filter[codes]=5OFFzzz&currency_prices=true

Note that the issue occurs regardless of whether the code I pass exists or not. (Even if the code does not exist I'd expect an empty array, and not an error 500).

So it would seem the Node SDK is incorrectly encoding the query parameters when providing a filter to the listCoupons method.

But I wanted to check with you all. Maybe I'm doing something wrong?

@maciej-nedza
Copy link
Contributor

Hey @hookdump, seems like it's bug in the SDK indeed (the other thing is the API shouldn't throw 500 in that case). We'll be looking into it and keep you updated, thanks for reporting.

@maciej-nedza
Copy link
Contributor

The issue has been fixed in 6.0.1

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

2 participants