Guard against null audit-log response in AuditOrganizationsClient - #32
Merged
Conversation
ApiConnection.Get<List<AuditLogEvent>> can deserialize to null for some
audit-log responses. The subsequent `!auditLogs.Any()` check then throws
ArgumentNullException ("Value cannot be null. (Parameter 'source')")
instead of treating the result as "no matching event".
Add a null guard to the three methods that follow this pattern
(GetRepositoryVisibilityChangeLastEvent, GetRepositoryCreatedLastEvent,
GetLastActivityDateImpl) so a null response returns null, matching the
existing empty-list behavior. Add regression tests and bump the package
version to 1.0.28.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
barnon-apiiro
approved these changes
Jul 2, 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.
Problem
AuditOrganizationsClient's audit-log query methods callApiConnection.Get<List<AuditLogEvent>>(...)and immediately evaluate!auditLogs.Any(). For some audit-log responses the payload deserializes tonullrather than an empty list, so.Any()throwsArgumentNullException(Value cannot be null. (Parameter 'source')) instead of reporting "no matching event".This affects all three methods that follow the pattern:
GetRepositoryVisibilityChangeLastEventGetRepositoryCreatedLastEventGetLastActivityDateImpl(used byGetLastActivityDateandGetUserLastActivityForRepositoryDate)Fix
Treat a
nullresponse the same as an empty one — returnnull(no event). Added a null guard at each site, plus regression tests, and bumped the package version to1.0.28.🤖 Generated with Claude Code