Skip to content

fix: Guard against null response data instead of throwing NullReferenceException - #312

Merged
razor-x merged 1 commit into
mainfrom
claude/csharp-sdk-locks-list-nre-gggyhx
Aug 6, 2026
Merged

fix: Guard against null response data instead of throwing NullReferenceException#312
razor-x merged 1 commit into
mainfrom
claude/csharp-sdk-locks-list-nre-gggyhx

Conversation

@razor-x

@razor-x razor-x commented Aug 6, 2026

Copy link
Copy Markdown
Member

Generated API methods dereferenced ApiResponse.Data without checking
for null. When a response deserializes to null — an empty or null JSON
body, a non-JSON body on a 2xx/3xx status, or a RestSharp deserialization
error captured on the response — callers got an opaque
NullReferenceException with no HTTP diagnostics.

Add ApiResponse.EnsureData(path), which returns the data or throws a
SeamException carrying the request path, HTTP status code, response
headers, and raw body, and update the codegen route template so every
generated endpoint uses it.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_015Ck3swavz8q3cmv52MJ5DL

…ceException

Generated API methods dereferenced ApiResponse<T>.Data without checking
for null. When a response deserializes to null — an empty or null JSON
body, a non-JSON body on a 2xx/3xx status, or a RestSharp deserialization
error captured on the response — callers got an opaque
NullReferenceException with no HTTP diagnostics.

Add ApiResponse<T>.EnsureData(path), which returns the data or throws a
SeamException carrying the request path, HTTP status code, response
headers, and raw body, and update the codegen route template so every
generated endpoint uses it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015Ck3swavz8q3cmv52MJ5DL
@razor-x
razor-x merged commit 677d292 into main Aug 6, 2026
14 checks passed
@razor-x
razor-x deleted the claude/csharp-sdk-locks-list-nre-gggyhx branch August 6, 2026 02:14
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