-
Notifications
You must be signed in to change notification settings - Fork 162
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
idempotencyKey parameter introduced in 4.36.0 breaks existing calls to accounting api #649
Comments
PETOSS-345 |
Thanks for raising an issue, a ticket has been created to track your request |
We have run into same problem. We attempted to use null/undefined for the |
At first, I tried to proactively fix this issue, as I thought it was a small bug. The specific solution is mentioned in #651. After analyzing the code, I discovered that the root cause of this issue is:
rootCause 1At first, I thought that root cause 1 would be relatively easy to fix. If we were to directly modify the code of the node version, it would be simple (though not advisable), just like how I fixed it in the closed PR: #651. All we need to do is:
just change it to the following:
However, upon closer examination of the code, I realized that it was generated using openApi generator, which complicated things. I attempted to achieve this by modifying the definition of idempotencyKey in the main project, located at https://github.com/XeroAPI/Xero-OpenAPI. Definition in version 4.36.0:
But no matter whether I try to add nullable as false or true, I can't make the generated code change.
I realized that it is impossible to achieve this by modifying the definition of the YAML file, and it may require modifying some template files mustache. Therefore, my suggestion is to fix the backend API of Xero so that the 'Idempotency-Key' in the http header can still function properly even if it is null/undefined. This can be resolved without having to upgrade the version of xero-node SDK, which will solve rootCause 1. rootCause 2In the xero-node SDK, some methods have added an optional parameter called 'idempotencyKey,' which disrupts the calling code of the original SDK, such as the updateOrCreateInvoices function. The updateOrCreateInvoices method in version 4.35.0 supports five parameters, which are as follows:
The method for version 4.36.0 has been changed to:
This causes the calling method of version 4.35.0 to recognize "summarizeErrors" as "idempotencyKey" in version 4.36.0. This results in a breaking change. Since this code is generated by the OpenAPI generator, we need you to consider whether the current way of calling optional parameters is appropriate and if it needs to be changed in the next version.
The order and number of parameters like this will not cause a break change. |
I just fix this issue manually updated the code in https://github.com/madison890000/xero-node. Here is the npm link I published: https://www.npmjs.com/package/fix-xero-node. You can use it by replacing
to
to upgrading you dependencies of xero-node from 4.35.0 to 4.36.0. I have only made two changes:
If the official updates to a new version and fixes this bug, you can switch back 'xero-node' again. |
I have a similar issue when using I assume it tries to serialize the latest options object as a string and using it as idempotency key in the request. First request succeeds because it's using I'm using the same options as the sample from the README for this function, with latest release 4.36.0: https://github.com/XeroAPI/xero-node#accounting-api I will try to downgrade for now until this is fixed. Thanks! |
This is the definition of
The example in readme is incorrect.
|
Thanks for the info, we will use TS for this part of our code in the future that will avoid future issues like that with Xero. The problems is see here:
I guess that I will need to be more careful with Xero updates in the future 😬 |
Yeah, and I don't know why. if you are have issues when you trying to upgrade from 4.35.0 to 4.36.0 to avoid breaking changes, you can try this: |
Hi all, Apologies for the delay. We have fixed the idempotency_key parameter issue in the SDK version 5.0.0. The idempotency_key is now the last optional parameter in the method definitions Do revert back to us if you are still facing any issues. Thank you for your patience! |
SDK you're using (please complete the following information):
xero-node Version 4.36.0
Describe the bug
Code which was currently working with version 4.35.0 of xero-node and which is using existing parameters such as
summarizeErrors
will now stop working (as I experienced today).Many accounting api call signatures (and possible other apis too) have been changed in 4.36.0. The new "optional"
idempotencyKey
parameter has sometimes been inserted in front of existing parametersFor example with https://xeroapi.github.io/xero-node/accounting/index.html#api-Accounting-updateOrCreateInvoices
the
idempotencyKey
parameter has, in v4.36.0, been inserted in front ot thesummarizeErrors
parameterTo Reproduce
Steps to reproduce the behavior:
Install version 4.35.0 xero-node
Create a simple call as per 4.35.0 docs (without
idempotencyKey
parameter) to update invoices along the lines of:Once working, then upgrade to xero-node version 4.36.0
Your api call now fails with
Expected behavior
The sequence of the call parameters for the accounting api must remain consistent. Any new parameters to existing api interface calls - such as
idempotencyKey
- must be added to the end of the parameter list, so that existing parameters/code remains unaffected.In version 4.36.0 the idempotencyKey parameter has sometimes been added to the end, sometimes in the middle of existing parameters of the various accounting api calls
The text was updated successfully, but these errors were encountered: