unexpected error while forging log: not found when running v2CreateBulk operation from generated openapi typescript sdk
#1961
Replies: 3 comments 3 replies
-
|
Hello! If you have opentelemetry traces enabled, you should have a more precise error regarding the failing request. |
Beta Was this translation helpful? Give feedback.
-
|
I just noticed you have a “where id = 0” in your sql request. |
Beta Was this translation helpful? Give feedback.
-
|
Hi! Well this is awkward for the delay it took me to come back into this issue, but after finally coming back to it, I did a more thorough investigation and realized that our openapi generator caused issues with models that have V2BulkElement:
type: object
oneOf:
- $ref: '#/components/schemas/V2BulkElementCreateTransaction'
- $ref: '#/components/schemas/V2BulkElementAddMetadata'
- $ref: '#/components/schemas/V2BulkElementRevertTransaction'
- $ref: '#/components/schemas/V2BulkElementDeleteMetadata'
discriminator:
propertyName: action
mapping:
CREATE_TRANSACTION: '#/components/schemas/V2BulkElementCreateTransaction'
ADD_METADATA: '#/components/schemas/V2BulkElementAddMetadata'
REVERT_TRANSACTION: '#/components/schemas/V2BulkElementRevertTransaction'
DELETE_METADATA: '#/components/schemas/V2BulkElementDeleteMetadata'basically, our generator generated this :
/**
* Ledger API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: v1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { RequestFile } from './models'
import { V2BulkElementAddMetadata } from './v2BulkElementAddMetadata'
import { V2BulkElementCreateTransaction } from './v2BulkElementCreateTransaction'
import { V2BulkElementDeleteMetadata } from './v2BulkElementDeleteMetadata'
import { V2BulkElementDeleteMetadataAllOfData } from './v2BulkElementDeleteMetadataAllOfData'
import { V2BulkElementRevertTransaction } from './v2BulkElementRevertTransaction'
export class V2BulkElement {
'action': string
'ik'?: string
'data'?: V2BulkElementDeleteMetadataAllOfData
static discriminator: string | undefined = 'action'
static attributeTypeMap: Array = [
{
name: 'action',
baseName: 'action',
type: 'string',
},
{
name: 'ik',
baseName: 'ik',
type: 'string',
},
{
name: 'data',
baseName: 'data',
type: 'V2BulkElementDeleteMetadataAllOfData',
},
]
static getAttributeTypeMap() {
return V2BulkElement.attributeTypeMap
}
}emphasis on the following lines : {
name: 'data',
baseName: 'data',
type: 'V2BulkElementDeleteMetadataAllOfData',
},the generated sdk serializer then always tried to serialize any operation as an and the request sent was therefore filled with : [
{
targetId: undefined,
targetType: undefined,
key: undefined
},
{
targetId: undefined,
targetType: undefined,
key: undefined
}
]which the ledger didn't know what to do with it basically, our generator was at fault, the api works as expected (as already mentioned few months ago), but I failed to see this issue few months back sorry about this! One thing I might ask is to have a better error in such case, as the But even then, this is definitely on us, thanks for taking the time to help me debug an issue that wasn't in your control at all, it was very appreciated and even reading this back it still is! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
While I'm not sure how much the openapi support is available and not given given as a "here it is, have fun with it", I'm trying to understand how could such an issue happen because the request I'm sending seem to be working, but I'm getting a ledger error.
In other words, maybe you guys have an idea on what could be happening here since I'm not sure how the internals of the ledger works :)
When running a
v2CreateBulkrequest through an api testing tool (Bruno in our case), the endpoint works perfectly as expected.When running the same query through a sdk generated from your openapi specs, I'm getting the error in the title :
Just to make the proper direction clear : I copied the request that was running through our own code through the openapi generated sdk, copied the body, then pasted and tried it in Bruno and that worked, so the issue is at the sdk level.
Essentially, we seem to be hit by this line :
https://github.com/formancehq/ledger/blob/82f6822c8ed6a964b0e14b2f98f62f5a715c2670/internal/controller/ledger/log_process.go#L125
Just for information since I don't want you guys to debug our sdk
we are using
npx -y @openapitools/openapi-generator-cli version-manager set 6.6.0templateDir: openapi-ts-template generatorName: typescript-node inputSpec: openapi.yaml additionalProperties: npmName: 'ledger-sdk' supportsES6: true files: README.md: {} .prettierignore: {} turbo.json: {}However, while debugging, since it seems the request is essentially the same (I debugged the internals, but I could have missed something), my question essentially boils down to :
What could be the reasons for an error about forging logs happening while doing a bulk request?
Our generated sdk also works for other api endpoints, it seems to only happen to the
v2CreateBulkendpoint.Any pointers would help, thanks a lot! :)
Beta Was this translation helpful? Give feedback.
All reactions