Skip to content

Add null safety for SyncId in GithubSyncService#114

Merged
afshinalizadeh merged 3 commits intofeature/afshin/add-sync-githubfrom
copilot/sub-pr-113
Dec 26, 2025
Merged

Add null safety for SyncId in GithubSyncService#114
afshinalizadeh merged 3 commits intofeature/afshin/add-sync-githubfrom
copilot/sub-pr-113

Conversation

Copy link
Contributor

Copilot AI commented Dec 26, 2025

The SyncId property is nullable but was used without null checks when creating dictionaries and working with HashSets, causing potential ArgumentNullException and NullReferenceException.

Changes

  • Dictionary creation: Filter documents with null/empty SyncId before ToDictionary() to prevent null key exceptions
  • Document processing loops: Skip documents with null/empty SyncId before HashSet operations
  • Consistent validation: Use string.IsNullOrWhiteSpace() uniformly across all three null check locations
// Before: throws ArgumentNullException if any SyncId is null
var existingDocMap = existingDocuments.ToDictionary(d => d.SyncInfo.SyncId, d => d);

// After: gracefully filters out null/empty SyncIds
var existingDocMap = existingDocuments
    .Where(d => !string.IsNullOrWhiteSpace(d.SyncInfo.SyncId))
    .ToDictionary(d => d.SyncInfo.SyncId!, d => d);

Documents with null SyncId are now silently skipped during sync operations rather than causing runtime failures.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 26, 2025 19:07
Co-authored-by: afshinalizadeh <4254006+afshinalizadeh@users.noreply.github.com>
Co-authored-by: afshinalizadeh <4254006+afshinalizadeh@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on sync GitHub feature implementation Add null safety for SyncId in GithubSyncService Dec 26, 2025
Copilot AI requested a review from afshinalizadeh December 26, 2025 19:13
@afshinalizadeh afshinalizadeh marked this pull request as ready for review December 26, 2025 20:56
@afshinalizadeh afshinalizadeh merged commit 9db3a1f into feature/afshin/add-sync-github Dec 26, 2025
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