Repository navigation
fix: expose unsupported content types as client exceptions - #2189
Merged
Vincent Biret (baywet) merged 3 commits intoSep 21, 2026
Merged
Vincent Biret (baywet) merged 3 commits into
Vincent Biret (baywet) merged 3 commits into
Conversation
Shubham Padkonde (Shubham-Padkonde)
requested a review
from a team
as a code owner
September 21, 2026 07:15
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
One or more issues must be addressed before approval.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Adds a dedicated unchecked ClientException for unsupported serialization and parsing content types.
Changes:
- Introduces
ClientExceptionwith standard constructors. - Updates both factory registries to throw it while preserving messages and validation behavior.
- Adds regression tests and a narrowly scoped SpotBugs exclusion.
| File | Description |
|---|---|
| components/abstractions/src/test/java/com/microsoft/kiota/serialization/FactoryRegistryExceptionTest.java | Updated as part of this pull request. |
| components/abstractions/src/main/java/com/microsoft/kiota/serialization/SerializationWriterFactoryRegistry.java | Updated as part of this pull request. |
| components/abstractions/src/main/java/com/microsoft/kiota/serialization/ParseNodeFactoryRegistry.java | Updated as part of this pull request. |
| components/abstractions/src/main/java/com/microsoft/kiota/ClientException.java | Updated as part of this pull request. |
| components/abstractions/spotBugsExcludeFilter.xml | Updated as part of this pull request. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Vincent Biret (baywet)
approved these changes
Sep 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #1683, following the proposed
ClientExceptionapproach in the issue discussion.An unregistered response content type, such as
text/htmlreturned during an outage, currently throws a plain RuntimeException from ParseNodeFactoryRegistry. Applications cannot distinguish this client-side processing failure without catching unrelated runtime errors. The serialization-writer registry has the same problem for unsupported request formats.Add ClientException as an unchecked exception with the standard message/cause constructors, and use it for missing-factory failures in both registries. The existing messages and argument-validation exception types are preserved. This provides a specific catch target separate from ApiException, which represents service error responses; it does not replace runtime exceptions throughout the rest of the library.
Regression coverage exercises unsupported response content types, both writer backing-store option values, unchanged invalid-argument behavior, and successful vendor-specific JSON resolution. With the original registry behavior, three cases fail and two controls pass. A narrowly scoped SpotBugs exclusion covers only deliberate null-argument calls in the validation test.
Validation: JDK 21, Gradle 9.7.1 (matching the wrapper), full
build -Pjava8=truewith the Java 8 compatibility toolchain, including Spotless and SpotBugs. No live Microsoft Graph requests or Android build were run.AI assistance: Codex assisted with implementation and validation. No separate human review is claimed.