question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Don't throw away the inner exception

See original GitHub issue

Description

The RestClient for SchemaRegistry throws away the inner exception:

https://github.com/confluentinc/confluent-kafka-dotnet/blob/9c5dfffbbd8ae80e3a08494a48b9a239b9872ffa/src/Confluent.SchemaRegistry/Rest/RestService.cs#L248

So that error messages become:

image

without an inner exception. Simply pass the caught exception into the c’tor to fix this issue.

How to reproduce

Make the schema registry TLS endpoint be something that this client doesn’t like.

Similarly, it’s impossible to override the logic for validating TLS certificates due to how the HttpClient is created:

https://github.com/confluentinc/confluent-kafka-dotnet/blob/9c5dfffbbd8ae80e3a08494a48b9a239b9872ffa/src/Confluent.SchemaRegistry/Rest/RestService.cs#L68-L75

This is doubly annoying because it would seem that, by explicitly creating a new HttpRequestMessage in CreateRequest, the global ServicePointManager.ServerCertificateValidationCallback that I tried setting, is overridden and defaulted.

Finally it’s annoying because it would seem that on macOS, .Net Core doesn’t default to using the system-configured certificates, so even if this certificate is valid for me outside .net, it’s not inside .net.

Checklist

I haven’t followed it because this issue is a review of the source code.

Please provide the following information:

  • A complete (i.e. we can run it), minimal program demonstrating the problem. No need to supply a project file.
  • Confluent.Kafka nuget version.
  • Apache Kafka version.
  • Client configuration.
  • Operating system.
  • Provide logs (with “debug” : “…” as necessary in configuration).
  • Provide broker log excerpts.
  • Critical issue.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mhowlettcommented, Oct 29, 2020

thanks @haf - I think you have made me realize we should allow the user to pass in their own HttpClient instance, or collection of them for HA.

from an API perspective, I think that means it’s time to introduce a SchemaRegistryClientBuilder, and this should create a ISchemaRegistryClient. I think CachedSchemaRegistryClient can remain user createable though as is, for now at least.

i probably won’t get to this immediately, but it shouldn’t be too hard. i’d probably be able to review a smallish high quality PR though to get it in quickly.

1reaction
mhowlettcommented, May 4, 2022

this hasn’t been addressed yet. will happily review PR for exposing inner exceptions and get it merged if it’s good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to rethrow InnerException without losing stack trace in ...
First: don't lose the TargetInvocationException - it's valuable information when you will want to debug things.
Read more >
Do Not Swallow The Exceptions
Here are a couple of examples of what I am talking about when I say swallowing the exception. Example 1: Totally Throwing Away...
Read more >
Don't throw exceptions in C#. Do this instead - YouTube
The deeper the call stack, the more overhead / boiler plate / noise you add to the code purely to avoid throwing an...
Read more >
The Exception Mistake You Must Never Make in C# - YouTube
Comments109. Robert Bauck Hamar. A related mistake might be not to provide the inner exception when throwing a new exception.
Read more >
Throw InnerException without loosing the stack trace
Option #2 – re-throwing the InnerExcpetion property. This at least preserves the type of the exception and thus code above you in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found