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

kiota crashes with NullReferenceException after update #6035

Open
bkoelman opened this issue Jan 17, 2025 · 5 comments
Open

kiota crashes with NullReferenceException after update #6035

bkoelman opened this issue Jan 17, 2025 · 5 comments
Labels
Csharp Pull requests that update .net code type:bug A broken experience

Comments

@bkoelman
Copy link

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

After update from v1.21.0 to v1.22.3, kiota crashes with the following error on Ubuntu:

  crit: Kiota.Builder.KiotaBuilder[0]
        error generating the client: One or more errors occurred. (Object reference not set to an instance of an object.) (Object reference not set to an instance of an object.)

Expected behavior

No crash.

How to reproduce

Run the following command:

dotnet kiota generate --language CSharp --class-name RestrictedControllersClient --namespace-name OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode --output ./GeneratedCode --backing-store --exclude-backward-compatible --clean-output --clear-cache --log-level Error --openapi ./swagger.g.json

Open API description file

Contents of swagger.g.json:

https://github.com/json-api-dotnet/JsonApiDotNetCore/blob/2212fc2c685446bebf86c905814a014f1a521cbd/test/OpenApiTests/RestrictedControllers/GeneratedSwagger/swagger.g.json

Kiota Version

1.22.3

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

1.21.0

Known Workarounds

None

Configuration

Ubuntu 24.04.1 LTS (GitHub Actions runner)

Debug output

No response

Other information

No response

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

Thanks for raising this @bkoelman

Unfourtunately, I'm not able to replicate the error using the openApi description and the arguments you provided.
Are you able to set the --log-level to Debug and share a trace to help us undestand better?
Is the failure consistent or does the success of the generation here flaky?

@andrueastman andrueastman removed the status:waiting-for-triage An issue that is yet to be reviewed or assigned label Jan 17, 2025
@andrueastman andrueastman moved this from Needs Triage 🔍 to Waits for author 🔁 in Kiota Jan 17, 2025
@andrueastman andrueastman added the status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close label Jan 17, 2025
@bkoelman
Copy link
Author

I'm unable to reproduce it anymore. I've tried 7x with debug switch on Windows/Ubuntu/macOS, then 6x without debug switch.

It would be helpful to dump the stack trace on the console in such cases.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Jan 18, 2025
@baywet
Copy link
Member

baywet commented Jan 20, 2025

Stack traces are enabled by default when built in debug. But we don't distribute debug builds.
We disabled it in release builds because we had received feedback a while ago that it was confusing for users.

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

@baywet baywet added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Jan 20, 2025
@bkoelman
Copy link
Author

Well, I agree that printing a stack trace for functional errors that are supposed to happen sometimes (for example: OAS file not found or invalid) is annoying for users.

But this one belongs to the class of errors that are never supposed to happen, and typically indicate an internal bug. I think they should always be printed with rich info, possibly asking to create an issue. Exceptions like NullReferenceException, TypeLoadException, DivideByZeroException, InvalidCastException, IndexOutOfRangeException, OverflowException etc. May also include FormatException and ArgumentException, depending on whether they could happen under normal circumstances.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Jan 20, 2025
@andrueastman
Copy link
Member

There's a chance this could be related to microsoft/OpenAPI.NET#1202. So, once we resolve #5936 and pull in a version with NRT information this may be resolved.

@andrueastman andrueastman moved this from Waits for author 🔁 to Blocked 🔒 in Kiota Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Csharp Pull requests that update .net code type:bug A broken experience
Projects
Status: Blocked 🔒
Development

No branches or pull requests

3 participants