microsoft / kiota-typescript

TypeScript libraries for Kiota-generated API clients.
https://aka.ms/kiota/docs
MIT License
32 stars 25 forks source link

`Content type application/json does not have a factory registered to be parsed` #1264

Open hognevevle opened 1 week ago

hognevevle commented 1 week ago

Following an upgrade to 1.16.0, I recently upgraded my app dependencies as instructed by Kiota.

Previous dependencies in package.json:

    "@microsoft/kiota-abstractions": "1.0.0-preview.56",
    "@microsoft/kiota-http-fetchlibrary": "1.0.0-preview.55",
    "@microsoft/kiota-serialization-form": "1.0.0-preview.45",
    "@microsoft/kiota-serialization-json": "1.0.0-preview.56",
    "@microsoft/kiota-serialization-multipart": "1.0.0-preview.34",
    "@microsoft/kiota-serialization-text": "1.0.0-preview.53",

CleanShot 2024-07-07 at 19 44 43

New dependencies in package.json:

    "@microsoft/kiota-abstractions": "1.0.0-preview.57",
    "@microsoft/kiota-http-fetchlibrary": "1.0.0-preview.56",
    "@microsoft/kiota-serialization-form": "1.0.0-preview.46",
    "@microsoft/kiota-serialization-json": "1.0.0-preview.57",
    "@microsoft/kiota-serialization-multipart": "1.0.0-preview.35",
    "@microsoft/kiota-serialization-text": "1.0.0-preview.54",

Unfortunately, I'm getting the following error after installing the new versions with yarn

Error: Content type application/json does not have a factory registered to be parsed
    at ParseNodeFactoryRegistry.getRootParseNode (parseNodeFactoryRegistry.ts:38:9)
    at fetchRequestAdapter.ts:374:34
    at async fetchRequestAdapter.ts:188:24
    at async fetchRequestAdapter.ts:166:12
    at async Proxy.init (cart.ts:75:24)

Tried deleting node_modules and reinstalling everything, to no avail.

Rolling back to the previous dependency versions does however fix the problem.

hognevevle commented 1 week ago

Possibly a duplicate of #1244. Close at will, or let me know if there's additional details I can provide.

andrueastman commented 1 week ago

Thanks for raising this @hognevevle

Any chance you can confirm the workaround provided at https://github.com/microsoft/kiota-typescript/issues/1244 works out for you? If so we can close this so that this can be followed up in that issue....

hognevevle commented 1 week ago

Hi @andrueastman , I don't use the Kiota CLI though -- only the VSCode extension. Is there a way to achieve the equivalent of --serializer none --deserializer none from the extension? If so I could try that.

baywet commented 1 week ago

@hognevevle in the extension it's a setting at this point.

image

nreinartz commented 2 days ago

The workaround seems to work, although you don't need to re-generate the kiota client without the serializers. Simply passing a custom parseNodeFactory (as shown in the example of #1244) to an existing client works.