Skip to content

feat: integrate asset count API for exact pagination totals (DX-9336)#295

Open
naman-contentstack wants to merge 1 commit into
v2-devfrom
feat/DX-9336
Open

feat: integrate asset count API for exact pagination totals (DX-9336)#295
naman-contentstack wants to merge 1 commit into
v2-devfrom
feat/DX-9336

Conversation

@naman-contentstack

Copy link
Copy Markdown
Contributor

Summary

Fixes silent truncation of AM exports for spaces with >10k assets/folders. The assets/folders list responses cap their count field at 10,000 server-side, so pagination planned from that count stopped at 10k and dropped everything beyond it.

Pagination in @contentstack/cli-asset-management is now driven by the dedicated count endpoint:

GET {csAssetsUrl}/api/bff/spaces/{space_uid}/assets/count?is_dir=<bool>&workspace=<ws>
→ { "count": N }   (exact, uncapped; is_dir=false → assets, true → folders)

Changes

  • Single-flow paginate(): takes a required, caller-resolved total — never derives totals from list responses, no fallback path to the capped count
  • getAssetsCount / getFoldersCount: authoritative totals for assets/folders; a missing/unfetchable total hard-fails the export (paginating blind = silent data loss)
  • Failed pages surface instead of vanishing: streamWorkspaceAssets returns { streamed, missing }; missing metadata records + failed binary downloads roll up as failedAssets into the export global summary (previously hardcoded failureCount = 0). Failed pages are recoverable via re-export/query-export, so they don't abort the run
  • limit=1 probe resolves totals for spaces/fields/asset_types (no count endpoint exists for these)
  • Removed dead getWorkspaceAssets (buffered variant): zero callers, and unbounded memory once the 10k cap is gone
  • .talismanrc: ignore entry for a false-positive secret pattern in a test title

Testing

  • contentstack-asset-management: 259 unit tests passing (12+ new: count API, single-flow pagination incl. beyond-cap planning, failed-page → missing, failedAssets propagation)
  • contentstack-export: 510 tests passing
  • Both packages compile clean (tsc -b)

Jira: DX-9336

🤖 Generated with Claude Code

The assets/folders list responses cap their count field at 10,000,
which silently truncated exports of spaces with more than 10k items.
Pagination is now driven by the dedicated count endpoint
(GET /api/bff/spaces/{uid}/assets/count, is_dir toggle for folders):

- paginate() takes a required caller-resolved total (single flow, no
  fallback to the capped response count)
- getAssetsCount/getFoldersCount fail the export when the exact total
  is unavailable (paginating blind means silent data loss)
- permanently failed pages no longer vanish: streamWorkspaceAssets
  returns { streamed, missing } and missing records surface as
  failedAssets in the export global summary (previously hardcoded 0)
- spaces/fields/asset_types resolve totals via a limit=1 probe
- remove dead buffered getWorkspaceAssets (zero callers, unbounded
  memory once the 10k cap is gone)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@naman-contentstack naman-contentstack requested a review from a team as a code owner July 16, 2026 10:15
@naman-contentstack naman-contentstack self-assigned this Jul 16, 2026
@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 1 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

⚠️ Warning: The following vulnerabilities have exceeded their SLA thresholds (days since publication).

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 1 90 / 365 days ⚠️ Warning
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ Vulnerabilities Without Available Fixes (Informational Only)

The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:

  • Critical without fixes: 0
  • High without fixes: 0
  • Medium without fixes: 1
  • Low without fixes: 0

⚠️ BUILD PASSED WITH WARNINGS - SLA breaches detected for issues without available fixes

Consider reviewing these vulnerabilities when fixes become available.

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.

1 participant