Skip to content

Harden Cloudflare pagination and tunnel status#749

Merged
ralyodio merged 1 commit into
profullstack:masterfrom
caydyan:codex/harden-cloudflare-pagination
Jun 14, 2026
Merged

Harden Cloudflare pagination and tunnel status#749
ralyodio merged 1 commit into
profullstack:masterfrom
caydyan:codex/harden-cloudflare-pagination

Conversation

@caydyan

@caydyan caydyan commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • continue Cloudflare list pagination when an endpoint omits result_info.total_pages but returns a full page
  • map Cloudflare tunnel active and errored statuses explicitly instead of sending errored through the provisioning fallback
  • add regression coverage for both cases

Context

Follow-up to #747 after Greptile marked these as non-blocking production hardening items on the merged Cloudflare adapter.

Testing

  • corepack pnpm --filter @profullstack/sh1pt-core build
  • corepack pnpm --filter @profullstack/sh1pt-cloud-cloudflare typecheck
  • corepack pnpm --filter @profullstack/sh1pt-cloud-cloudflare build
  • corepack pnpm vitest run packages/cloud/cloudflare/src/index.test.ts (19 tests)
  • git diff --check origin/master...HEAD

@github-actions

Copy link
Copy Markdown

🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: git fetch upstream master && git rebase upstream/master.

1 similar comment
@github-actions

Copy link
Copy Markdown

🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: git fetch upstream master && git rebase upstream/master.

@greptile-apps

greptile-apps Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR hardens the Cloudflare adapter in two areas: the cfListAll pagination loop now falls back to a size-based continuation heuristic (pageItems.length >= perPage) when the API response omits result_info.total_pages, and tunnelStatus gains explicit mappings for active, errored, error, unhealthy, and several provisioning-phase statuses rather than letting them fall through to 'provisioning'.

  • Pagination (cfListAll): The do…while condition is replaced with a shouldContinue flag. When total_pages is present, behavior is identical to before. When absent, the loop continues only if the last page was full (100 items), which means at most one extra empty request on a page boundary — a standard, well-understood trade-off for cursor-free pagination.
  • Tunnel status (tunnelStatus): All branch comparisons are now case-insensitive via status?.toLowerCase(), and new statuses (active, running, stopped, errored, error, failed, unhealthy, pending, initializing) are explicitly handled before the catch-all 'provisioning' return.
  • Tests: Both changes are covered by dedicated regression tests that mock the Cloudflare API at the fetch level and assert exact call counts and response shapes.

Confidence Score: 5/5

Safe to merge — both changes are isolated, well-tested, and represent pure additive hardening with no behaviour changes on existing code paths.

The pagination change is a straightforward guard around a missing field; the fallback heuristic is a standard industry pattern and the worst-case side effect is a single extra API call on a perfectly-aligned page boundary. The status mapping change only adds new explicit cases ahead of an existing catch-all, leaving all previously-mapped statuses unchanged. Both changes are covered by targeted regression tests with call-count assertions.

No files require special attention.

Important Files Changed

Filename Overview
packages/cloud/cloudflare/src/index.ts Pagination hardened with size-based continuation heuristic when total_pages is absent; tunnelStatus expanded with explicit mappings for active, errored, and related statuses.
packages/cloud/cloudflare/src/index.test.ts Two new regression tests added: pagination without total_pages (101-item across 2 pages) and explicit tunnel status mapping for active→running and errored→failed.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[cfListAll called] --> B[page = 1, shouldContinue = true]
    B --> C[Fetch page N with per_page=100]
    C --> D[Parse pageItems from result]
    D --> E{resultInfo.total_pages is a number?}
    E -->|Yes| F[shouldContinue = page < total_pages]
    E -->|No| G[shouldContinue = pageItems.length >= 100]
    F --> H[page += 1]
    G --> H
    H --> I{shouldContinue?}
    I -->|Yes| C
    I -->|No| J[Return all collected items]

    subgraph tunnelStatus
        K[status input] --> L[normalize to lowercase]
        L --> M{normalized value}
        M -->|healthy / active / running| N[running]
        M -->|inactive / down / stopped| O[stopped]
        M -->|degraded / errored / error / failed / unhealthy| P[failed]
        M -->|pending / provisioning / initializing| Q[provisioning]
        M -->|empty / unknown| R[provisioning]
    end
Loading

Reviews (1): Last reviewed commit: "Harden Cloudflare pagination and tunnel ..." | Re-trigger Greptile

@ralyodio ralyodio merged commit 9166ce4 into profullstack:master Jun 14, 2026
5 checks passed
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