Skip to content

fix: reduce ListUsers MaxResults from 200 to 50 to prevent Lambda OOM/timeout#104

Open
c1-dev-bot[bot] wants to merge 1 commit into
mainfrom
fix/reduce-list-users-page-size
Open

fix: reduce ListUsers MaxResults from 200 to 50 to prevent Lambda OOM/timeout#104
c1-dev-bot[bot] wants to merge 1 commit into
mainfrom
fix/reduce-list-users-page-size

Conversation

@c1-dev-bot
Copy link
Copy Markdown

@c1-dev-bot c1-dev-bot Bot commented May 19, 2026

Summary

  • Reduces MaxResults for ListUsers from 200 to 50 to prevent Lambda OOM/timeout crashes on tenants with large Google Workspace directories
  • ListUsers uses Projection("full") which returns extensive per-user data (organizations, custom schemas, relations, POSIX accounts, etc.) — with 200 users per page, directories with many custom-schema attributes can produce payloads large enough to exceed Lambda memory limits or trigger context deadline timeouts
  • The crash manifests as FunctionError=Unhandled with status code: 200 because OOM/panic falls through the baton-sdk Lambda client's timeout detection logic at pkg/lambda/grpc/client.go:62-68 to the generic error format at line 75
  • Reducing to 50 users per page bounds per-page payload size (~75% reduction) while maintaining correct pagination — the tradeoff is more API calls per sync, but each call completes safely within Lambda constraints

Context

This matches the pattern seen in CE-582 where an identical lambda_transport: Unhandled; status code: 200 error was caused by Lambda timeout on large directory listing. The affected tenant has never completed a successful full sync.

Test plan

  • Verify the connector builds successfully
  • CI passes
  • Engineering should confirm via CloudWatch logs whether the crash is OOM or timeout to validate this fix addresses the root cause
  • If OOM: this fix directly addresses it by reducing per-page memory usage
  • If timeout: this fix helps by reducing per-page transfer and parse time; Lambda timeout increase may also be needed
  • Deploy to affected tenant and verify sync completes

Fixes: CXH-1509


Automated PR Notice

This PR was automatically created by c1-dev-bot as a potential implementation.

This code requires:

  • Human review of the implementation approach
  • Manual testing to verify correctness
  • Approval from the appropriate team before merging

…/timeout

ListUsers with Projection("full") returns extensive per-user data including
organizations, custom schemas, relations, and POSIX accounts. For directories
with many custom-schema attributes, a page of 200 users can produce payloads
large enough to exceed Lambda memory limits or trigger context deadline
timeouts, resulting in FunctionError=Unhandled crashes.

Reducing MaxResults to 50 bounds the per-page payload size to prevent these
crashes while maintaining correct pagination behavior. The tradeoff is more
API calls per sync, but each call completes safely within Lambda constraints.

Fixes: CXH-1509
@c1-dev-bot c1-dev-bot Bot requested a review from a team May 19, 2026 21:25
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 19, 2026

CXH-1509

@github-actions
Copy link
Copy Markdown
Contributor

Connector PR Review: fix: reduce ListUsers MaxResults from 200 to 50 to prevent Lambda OOM/timeout

Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Review mode: full
View review run

Review Summary

This PR reduces the MaxResults parameter for ListUsers from 200 to 50 in pkg/client/client.go to prevent Lambda OOM/timeout crashes when syncing large Google Workspace directories with Projection("full"). The pagination mechanism via pageToken is unchanged, so correctness is preserved — this is a safe tuning change (B9). No security, correctness, or breaking change issues found.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

No blocking issues found.

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.

0 participants