Skip to content

fix(openai): handle null statusCode in HttpTransportException to prevent NPE#928

Open
shlokmestry wants to merge 2 commits intoagentscope-ai:mainfrom
shlokmestry:fix/openai-client-npe-status-code
Open

fix(openai): handle null statusCode in HttpTransportException to prevent NPE#928
shlokmestry wants to merge 2 commits intoagentscope-ai:mainfrom
shlokmestry:fix/openai-client-npe-status-code

Conversation

@shlokmestry
Copy link
Contributor

1.0.10-SNAPSHOT

Fixes a NullPointerException in OpenAIClient.stream() caused by auto-unboxing
a nullable Integer when HttpTransportException has no HTTP status code
(e.g. connection failure, DNS error, timeout).

The existing code passed getStatusCode() (return type Integer, nullable)
directly to OpenAIException.create(int, ...), which throws an NPE when
statusCode is null.

Fix: Added a null check before accessing getStatusCode(). If null, falls back
to new OpenAIException(msg, ex) instead of crashing.

Fixes #891

@shlokmestry shlokmestry requested a review from a team March 11, 2026 21:48
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.

NPE in OpenAIClient: HttpTransportException.getStatusCode() null auto-unboxing

1 participant