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

Broken output after converting to workspace in vscode #5782

Closed
erwinkramer opened this issue Nov 14, 2024 · 3 comments
Closed

Broken output after converting to workspace in vscode #5782

erwinkramer opened this issue Nov 14, 2024 · 3 comments
Labels
generator Issues or improvements relater to generation capabilities. status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question

Comments

@erwinkramer
Copy link

erwinkramer commented Nov 14, 2024

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Nuget tool

Client library/SDK language

Csharp

Describe the bug

I had a lock file like this, generated by the CLI tool:

{
  "descriptionHash": "A8B3FF4FA538A2BB028EFB20C76C6CF203DF1A960CE76CF3AF6519312C4D211D046AE60754840416BF67F8B7AF6BEE0693E9628FB6C06139021D9CE60F82B1EB",
  "descriptionLocation": "../../../specs-downstream/github-api.json",
  "lockFileVersion": "1.0.0",
  "kiotaVersion": "1.20.0",
  "clientClassName": "GitHubClient",
  "typeAccessModifier": "Public",
  "clientNamespaceName": "DownstreamClients.GitHub",
  "language": "CSharp",
  "usesBackingStore": false,
  "excludeBackwardCompatible": false,
  "includeAdditionalData": true,
  "disableSSLValidation": false,
  "serializers": [
    "Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory",
    "Microsoft.Kiota.Serialization.Text.TextSerializationWriterFactory",
    "Microsoft.Kiota.Serialization.Form.FormSerializationWriterFactory",
    "Microsoft.Kiota.Serialization.Multipart.MultipartSerializationWriterFactory"
  ],
  "deserializers": [
    "Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory",
    "Microsoft.Kiota.Serialization.Text.TextParseNodeFactory",
    "Microsoft.Kiota.Serialization.Form.FormParseNodeFactory"
  ],
  "structuredMimeTypes": [
    "application/json",
    "text/plain;q=0.9",
    "application/x-www-form-urlencoded;q=0.2",
    "multipart/form-data;q=0.1"
  ],
  "includePatterns": [
    "/repos/{owner}/{repo}/releases/*"
  ],
  "excludePatterns": [],
  "disabledValidationRules": []
}

Then i decided to remove the CLI tool and go with the VSCode extension. This resulted in the extention asking me if i want to convert to a workspace-based Kiota setup, fine, i press OK. This results into the following workspace:

{
  "version": "1.0.0",
  "clients": {
    "GitHubClient": {
      "language": "CSharp",
      "typeAccessModifier": "Public",
      "structuredMimeTypes": [
        "application/json",
        "text/plain;q=0.9",
        "application/x-www-form-urlencoded;q=0.2",
        "multipart/form-data;q=0.1"
      ],
      "clientNamespaceName": "DownstreamClients.GitHub",
      "usesBackingStore": false,
      "includeAdditionalData": true,
      "excludeBackwardCompatible": false,
      "disabledValidationRules": [],
      "descriptionLocation": "./specs-downstream/github-api.json",
      "includePatterns": [
        "/repos/{owner}/{repo}/releases/*"
      ],
      "excludePatterns": [],
      "outputPath": "./bank-api-minimal/DownstreamClients/GitHub"
    }
  },
  "plugins": {}
}

Now i re-generate the client-code by pressing "Re-generate" in the workspace.json.

At this point, my client differs, the following lines are removed in my client:

  ApiClientBuilder.RegisterDefaultSerializer<JsonSerializationWriterFactory>();
  ApiClientBuilder.RegisterDefaultSerializer<TextSerializationWriterFactory>();
  ApiClientBuilder.RegisterDefaultSerializer<FormSerializationWriterFactory>();
  ApiClientBuilder.RegisterDefaultSerializer<MultipartSerializationWriterFactory>();
  ApiClientBuilder.RegisterDefaultDeserializer<JsonParseNodeFactory>();
  ApiClientBuilder.RegisterDefaultDeserializer<TextParseNodeFactory>();
  ApiClientBuilder.RegisterDefaultDeserializer<FormParseNodeFactory>();

And results in the error at runtime (compiles just fine):

An exception of type 'System.InvalidOperationException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'Content type application/json does not have a factory registered to be parsed'

which makes sense considering there was an addition (which Kiota decided it needed while using the CLI) in the lock file which didn't get ported over to the workspace:

 "serializers": [
    "Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory",
    "Microsoft.Kiota.Serialization.Text.TextSerializationWriterFactory",
    "Microsoft.Kiota.Serialization.Form.FormSerializationWriterFactory",
    "Microsoft.Kiota.Serialization.Multipart.MultipartSerializationWriterFactory"
  ],
  "deserializers": [
    "Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory",
    "Microsoft.Kiota.Serialization.Text.TextParseNodeFactory",
    "Microsoft.Kiota.Serialization.Form.FormParseNodeFactory"
  ],

Expected behavior

Should be a working and smooth transition.

How to reproduce

Working setup is at https://github.com/erwinkramer/bank-api?tab=readme-ov-file#bank-api

Open API description file

No response

Kiota Version

1.20.0+81bdb1bf13383a749f794d47926d09733d2d7be1

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

No response

Configuration

  • OS Windows 11
  • x64

Debug output

No response

Other information

No response

@erwinkramer erwinkramer added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Nov 14, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Kiota Nov 14, 2024
@msgraph-bot msgraph-bot bot added the Csharp Pull requests that update .net code label Nov 14, 2024
@baywet
Copy link
Member

baywet commented Nov 15, 2024

Hi @erwinkramer
Thank you for using kiota and for reaching out.

This is by design, we want to make the clients more portable with this iteration.
What's odd for you in terms of experience, is that there's no documentation on the migration process and the vscode experience is providing the new workspace system while the CLI is still using the lock experience.
We're working on planning, to official bump the version to a v2 and clean this up.

Trying using DefaultRequestAdapter from Microsoft.Kiota.Bundle instead that should get your application working again.

Let us know if you have any additional comments or questions.

@baywet baywet added generator Issues or improvements relater to generation capabilities. status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question and removed type:bug A broken experience Csharp Pull requests that update .net code status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Nov 15, 2024
@baywet baywet moved this from Needs Triage 🔍 to Waits for author 🔁 in Kiota Nov 15, 2024
@erwinkramer
Copy link
Author

Thanks, using DefaultRequestAdapter solved it.

@github-project-automation github-project-automation bot moved this from Waits for author 🔁 to Done ✔️ in Kiota Nov 16, 2024
@thompson-tomo
Copy link

I also ran into this issue when i upgraded to the workspace file and spent quite a while debugging until i found this issue. :( Fortunately my solution is now working and i am able to talk to the api's. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generator Issues or improvements relater to generation capabilities. status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question
Projects
Status: Done ✔️
Development

No branches or pull requests

3 participants