fix(tier-client): avoid 414 URI Too Large on orgs with many enrollments#1390
Merged
fix(tier-client): avoid 414 URI Too Large on orgs with many enrollments#1390
Conversation
Rewrite getAllEnrollment() and getFirstEnrollment() to eliminate the oversized GET URLs that PostgREST generates when batchGetByKeys is called with hundreds of UUIDs. - getAllEnrollment: site-specific path uses findById instead of batchGetByKeys; org-only path chunks batchGetByKeys into groups of 50 - getFirstEnrollment: now standalone (no longer calls getAllEnrollment); site-specific path does in-memory match; org-only path iterates with findById and early exit Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
solaris007
approved these changes
Mar 1, 2026
Member
solaris007
left a comment
There was a problem hiding this comment.
Clean fix for the 414 URI Too Large on orgs with many enrollments.
getAllEnrollment() changes:
- Site-specific path: single
findByIdinstead of batch fetch of all sites - Org-only path: chunks
batchGetByKeysinto groups of 50 - fixes the 414 while preserving existing behavior
getFirstEnrollment() rewrite:
- Now standalone - no longer calls
getAllEnrollment()which was wasteful (fetching ALL sites just to return one) - Site-specific path: in-memory filter + returns
this.sitedirectly - zero DB calls for the site - Org-only path: iterates with
findById+ early exit on first match
Test coverage looks solid - 70 tests, 100% coverage, edge cases covered.
One note: The org-only getFirstEnrollment does sequential findById calls in a loop. Fine for this use case (early exit), but if most enrollments pointed to sites in other orgs it could make many individual calls before finding a match. Not a practical concern since enrollments are typically scoped correctly - just worth being aware of.
LGTM.
solaris007
pushed a commit
that referenced
this pull request
Mar 1, 2026
## [@adobe/spacecat-shared-tier-client-v1.3.13](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tier-client-v1.3.12...@adobe/spacecat-shared-tier-client-v1.3.13) (2026-03-01) ### Bug Fixes * **tier-client:** avoid 414 URI Too Large on orgs with many enrollments ([#1390](#1390)) ([2e9de5e](2e9de5e))
Member
|
🎉 This PR is included in version @adobe/spacecat-shared-tier-client-v1.3.13 🎉 The release is available on: Your semantic-release bot 📦🚀 |
4 tasks
ekremney
added a commit
that referenced
this pull request
Mar 1, 2026
) ## Summary - PostgREST `batchGetByKeys` uses `.in(field, values)` which generates GET URLs like `?id=in.(uuid1,uuid2,...)`. With hundreds of keys, this exceeds HTTP URL length limits causing **414 Request-URI Too Large**. - Splits the `.in()` call into chunks of 50 keys (~1,800 chars per chunk, well under the 8KB URL limit) and merges results. - This is a defense-in-depth fix at the data-access layer. All callers of `batchGetByKeys` are now automatically protected. See also #1390 for the TierClient-specific fix. ## Test plan - [x] All 121 base collection unit tests pass - [x] New test verifies 120 keys are split into 3 chunks (50 + 50 + 20) - [x] Existing tests unchanged and passing (small batches still use a single `.in()` call) - [x] ESLint clean 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
solaris007
pushed a commit
that referenced
this pull request
Mar 1, 2026
## [@adobe/spacecat-shared-data-access-v3.4.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.4.0...@adobe/spacecat-shared-data-access-v3.4.1) (2026-03-01) ### Bug Fixes * **data-access:** chunk batchGetByKeys to avoid 414 URI Too Large ([#1391](#1391)) ([25b0c0d](25b0c0d)), closes [#1390](#1390)
ekremney
added a commit
that referenced
this pull request
Mar 4, 2026
…roposal - Distinguish between individually-inefficient methods and methods called in N+1 patterns by consumers - Split checkValidEntitlement replacement into org-only and with-site variants - Acknowledge product-specific business logic concern for createEntitlement - Add migration note about plain objects vs model instances - Reference PRs #1390 and #1391 for chunking context - Add trailing newline Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
batchGetByKeysgenerates GET requests with?id=in.(uuid1,uuid2,...)in the URL. For orgs with hundreds of site enrollments, this exceeds HTTP URL length limits causing 414 Request-URI Too Large.getAllEnrollment(): When a specific site is provided, skips batch fetch entirely and uses a singlefindByIdcall. For org-only path, chunksbatchGetByKeysinto groups of 50 IDs (~1,800 chars per chunk, well under 8KB limit).getFirstEnrollment(): Now standalone (no longer callsgetAllEnrollment). Site-specific path does in-memory match and returnsthis.sitedirectly. Org-only path iterates enrollments withfindByIdone at a time with early exit on first match.Test plan
sites-resolveendpoint with AEM Reference Demo org (the org that was hitting 414)🤖 Generated with Claude Code