Skip to content

Conversation

@mkopcil
Copy link

@mkopcil mkopcil commented Nov 3, 2025

What

There are two changes:

  1. Added AggregateException as an inner exception of the final thrown HttpRequestException.
  2. Added an additional try-catch block when parsing the content of a non-retriable HttpResponse. If the content is not JSON, we throw an HttpRequestException as an InnerException with the corresponding StatusCode.

Why

  1. This change was made to avoid suppressing exceptions when communicating with the SchemaRegistry. We discovered that when using the AVRO schema for deserializing a Kafka message, we would get an error:

    Confluent.Kafka.ConsumeException: Local: Value deserialization error ---> System.Net.Http.HttpRequestException: [https://xxx/] HttpRequestException: An error occurred while sending the request.
    

    without propagating the response StatusCode. In this case, the status was 403: Forbidden. This change makes it easier to debug networking errors.

  2. Similar to the first change, this occurred when serializing a Kafka message in the producer using the AVRO schema registry. We received an error:

    Local: Value serialization error ---> ; error code: -1
    

    Debugging revealed that this happened when the HttpResponse.StatusCode was 403: Forbidden, and parsing into JSON failed. The default value of errorCode (-1) was then thrown as a SchemaRegistryException.

Checklist

  • Contains customer-facing changes? Including API/behavior changes

    • The exceptions thrown will remain the same, but they will now include inner exceptions with the necessary information.
  • Did you add sufficient unit and/or integration test coverage for this PR?

    • Since the changes only add additional information to the exceptions, I ensured that existing tests still pass and did not add new ones.

Open Questions / Follow-ups

The method ExecuteOnOneInstanceAsync may need further review, as these fixes might not be sufficient for different HttpResponse scenarios.

…to capture multiple exceptions, since a single string message is insufficient.

- If the response is non-retriable and JSON parsing fails, throw HttpRequestException including StatusCode and response content.
@mkopcil mkopcil requested review from a team as code owners November 3, 2025 10:00
@rayokota
Copy link
Member

rayokota commented Nov 3, 2025

/sem-approve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants