Skip to content

Fixes null reference exception bug when APX returns a 202 response w/o body when sending an activity#419

Merged
singhk97 merged 7 commits intonext/corefrom
next/oauth-card-null-ref-bug-fix
Apr 9, 2026
Merged

Fixes null reference exception bug when APX returns a 202 response w/o body when sending an activity#419
singhk97 merged 7 commits intonext/corefrom
next/oauth-card-null-ref-bug-fix

Conversation

@singhk97
Copy link
Copy Markdown
Collaborator

@singhk97 singhk97 commented Apr 9, 2026

Null-safe Handling of Send Activity Responses:

  • Changed the return type of SendAsync in ActivitiesApi.cs to Task<SendActivityResponse?>, allowing for null responses when the service returns no body.
  • Updated TeamsStreamingWriter.cs to handle potentially null SendActivityResponse objects in both SendInformativeUpdateAsync and AppendResponseAsync, ensuring _streamId is only set if a response is present. [1] [2]
  • Modified CompatConversations.cs to handle null SendActivityResponse objects when replying to activities, defaulting the resource response ID to an empty string if necessary.

singhk97 and others added 7 commits April 8, 2026 11:18
Add tests to verify that when APX returns 202 Accepted with no body:
- SendToConversationWithHttpMessagesAsync returns string.Empty for Id
- ReplyToActivityWithHttpMessagesAsync returns string.Empty for Id

This ensures the fix maintains API contract by never returning null for ResourceResponse.Id

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Update ConversationClientTests to handle nullable SendActivityResponse
- Update Proactive Worker sample to handle nullable response

Fixes CI build errors after making SendActivityAsync return nullable.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Update ConversationClientTest to handle nullable SendActivityResponse (8 occurrences)
- Update TeamsApiFacadeTests to handle nullable SendActivityResponse (5 occurrences)

This completes the nullability fixes for all test files.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
ResourceResponse resourceResponse = new()
{
Id = response.Id
Id = response?.Id ?? string.Empty
Copy link
Copy Markdown
Collaborator Author

@singhk97 singhk97 Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string.Empty to not break api contract. ResourceResponse.Id is a string.

@rido-min rido-min added the CORE label Apr 9, 2026
@singhk97 singhk97 merged commit cde28c8 into next/core Apr 9, 2026
8 checks passed
@singhk97 singhk97 deleted the next/oauth-card-null-ref-bug-fix branch April 9, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants