fix(SA-675): Google GitHub sync fixes #787
Open
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.
Fixes Google to GitHub user synchronisation issues identified in SA-675.
Fix 1: Archived Google users receiving GitHub invites
Problem: Users marked as archived or suspended in Google Workspace were still being detected as active. If they had a GitHub ID in their profile, the sync would send them an org invite.
Root cause: The Google Directory API query wasn't filtering out suspended/archived users, and the application had no secondary check.
Solution:
src/google.tsquery: 'isSuspended=false'to Google API request to filter suspended users at sourcesrc/google.tssuspended,archivedtofieldsparameter to retrieve these flagssrc/google.ts.filter((user) => !user.suspended && !user.archived)as secondary filter for archived users (Google API doesn't supportisArchivedquery param)Why both filters? Google API supports
isSuspendedquery filter but notisArchived. The API-level filter reduces data transfer, the application-level filter catches archived users.Tests:
tests/google.spec.tslines 73-84Fix 2: Pipeline failure on successful membership changes
Problem: When the sync detected a mismatch and successfully added/removed users, it still exited with non-zero code, causing pipeline failures even though the operation succeeded.
Root cause: Original logic:
exitCode = (anyMismatch) ? nonZero : 0— any detected difference triggered failure exit, regardless of whether it was resolved.Solution:
index.tsunfixedMismatchflag, only settruewhen mismatch exists AND corresponding action (ADD_USERS/REMOVE_USERS) is disabledindex.tsexitCode = (unfixedMismatch || hasErrors) ? nonZero : 0New behaviour:
Tests:
tests/index.spec.tslines 40-52Fix 3: Silent failure on org capacity limit
Problem: When GitHub org hit max user count, the API returned 422 error which was not caught or surfaced. Sync appeared to succeed but users weren't actually added.
Root cause: No try/catch around GitHub API calls, no error aggregation or reporting.
Solution:
src/github.tsOperationErrorandOperationResultinterfaces to track individual operation outcomessrc/github.tscreateInvitationin try/catch, parse error status codessrc/github.ts"Validation failed: ... (user may already be invited, or org is at max capacity)"src/github.tsindex.ts--- ERRORS SUMMARY ---with each failed operationError visibility: All errors collected during run, summarised at end with operation type, username, and error message.
Tests:
tests/github.spec.tslines 109-130 ("handles 422 error (org full)")Fix 4: No Slack notifications
Problem: No way to know when membership changes occurred or when errors happened without checking pipeline logs.
Solution:
src/slack.tssrc/config.tsaction.ymlindex.tsnotifySlack()after operations completeConfiguration options:
slack-webhook-urlslack-notify-on-errortrueslack-notify-on-changefalseslack-notify-alwaysfalseMessage format: Slack Block Kit with header, lists of added/removed users, error details if any.
Tests:
tests/slack.spec.ts(full test suite)Fix 5: Outdated libraries
Problem: Node.js 15.x EOL, GitHub Actions v3 deprecated (actions/cache v3.3.1 blocked by GitHub Dec 2024).
Solution:
.nvmrc16.20.0→18.20.0.github/workflows/ci.yml:1015.12.0→18.20.0.github/workflows/ci.yml:17actions/checkoutv3.5.2 → v4.2.2.github/workflows/ci.yml:19actions/setup-nodev3.6.0 → v4.1.0.github/workflows/ci.yml:23actions/cachev3.3.1 → v4.2.3Deferred: npm package updates (octokit, jest, eslint) have breaking API changes — recommend separate PR with dedicated testing.
Test Coverage Summary
google.spec.tsindex.spec.tsgithub.spec.tsslack.spec.tsHow to Test
ADD_USERS=true, verify exit 0 when users added successfullyNext Steps After Merge
1. Create release & build Docker image