Skip to content

Guard against null audit-log response in AuditOrganizationsClient - #32

Merged
idanbd merged 1 commit into
mainfrom
idan/guard-null-audit-log-response
Jul 2, 2026
Merged

Guard against null audit-log response in AuditOrganizationsClient#32
idanbd merged 1 commit into
mainfrom
idan/guard-null-audit-log-response

Conversation

@idanbd

@idanbd idanbd commented Jul 1, 2026

Copy link
Copy Markdown

Problem

AuditOrganizationsClient's audit-log query methods call ApiConnection.Get<List<AuditLogEvent>>(...) and immediately evaluate !auditLogs.Any(). For some audit-log responses the payload deserializes to null rather than an empty list, so .Any() throws ArgumentNullException (Value cannot be null. (Parameter 'source')) instead of reporting "no matching event".

This affects all three methods that follow the pattern:

  • GetRepositoryVisibilityChangeLastEvent
  • GetRepositoryCreatedLastEvent
  • GetLastActivityDateImpl (used by GetLastActivityDate and GetUserLastActivityForRepositoryDate)

Fix

Treat a null response the same as an empty one — return null (no event). Added a null guard at each site, plus regression tests, and bumped the package version to 1.0.28.

🤖 Generated with Claude Code

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>
@idanbd
idanbd requested a review from barnon-apiiro July 2, 2026 06:27
@idanbd
idanbd merged commit eb85a90 into main Jul 2, 2026
0 of 3 checks passed
@idanbd
idanbd deleted the idan/guard-null-audit-log-response branch July 2, 2026 07:36
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