Skip to content

fix(apps-vtex,blocks): PLP pagination stuck on page 1 for ?page=N (#391) - #394

Merged
JonasJesus42 merged 1 commit into
mainfrom
fix/391-plp-pagination-page1
Jul 26, 2026
Merged

JonasJesus42 merged 1 commit into
mainfrom
fix/391-plp-pagination-page1

Conversation

@JonasJesus42

@JonasJesus42 JonasJesus42 commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • productListingPage.ts used Number.isFinite(rawPage) to validate props.page, but Number.isFinite does NOT coerce — a string page value silently fell back to page 0. Extracted the logic into an exported, unit-tested resolvePage() helper that coerces first and only falls through to the URL parse when the coerced value is non-finite.
  • resolve.ts's commerce-loader URL search-param auto-injection populated props.page with the raw 1-indexed URL string, bypassing the loader's own 1-indexed→0-indexed conversion (a second, independent off-by-one on top of the string bug). page is now skipped in that injection loop; count/pageOffset are coerced to numbers instead of raw strings.

Fixes #391

Test plan

  • resolvePage() unit tests: string coercion, malformed URL param, props.page priority over URL, floor/negative clamping
  • resolve.ts tests: page never auto-injected, count/pageOffset coerced to number
  • bunx vitest run green for both touched packages
  • tsc --noEmit clean for apps-vtex and blocks

🤖 Generated with Claude Code


Summary by cubic

Fixes PLP pagination getting stuck on page 1 when using ?page=N by correctly coercing and converting page values. Prevents off-by-one errors from URL param injection. Fixes #391.

  • Bug Fixes
    • apps-vtex: Added resolvePage() to coerce props.page, parse ?page= (1-indexed → 0-indexed), floor values, and clamp negatives.
    • blocks: Stopped auto-injecting page from URL into loader props; count and pageOffset are now coerced to numbers.
    • Added unit tests for both changes.

Written for commit 765d418. Summary will update on new commits.

Review in cubic

…uests

Two compounding defects (production repro on farmrio-storefront):

1. productListingPage.ts used `Number.isFinite(rawPage)` to validate
   `props.page`, but `Number.isFinite` does NOT coerce — a string page
   value silently fell back to page 0 instead of being parsed. Extracted
   the page-resolution logic into an exported `resolvePage()` helper that
   coerces first and only falls back to the URL parse when the coerced
   value is non-finite.

2. resolve.ts's commerce-loader URL search-param auto-injection populated
   `props.page` with the raw 1-indexed URL string, bypassing the loader's
   own 1-indexed → 0-indexed conversion and producing an off-by-one on top
   of the un-coerced-string bug. `page` is now skipped in that injection
   loop (loaders that read `__pageUrl` apply their own conversion);
   `count`/`pageOffset` are coerced to numbers instead of raw strings.

Fixes #391

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@JonasJesus42
JonasJesus42 requested a review from a team July 25, 2026 23:47
@JonasJesus42
JonasJesus42 merged commit 28757f8 into main Jul 26, 2026
1 check passed
@JonasJesus42
JonasJesus42 deleted the fix/391-plp-pagination-page1 branch July 26, 2026 00:22
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 7.22.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

JonasJesus42 added a commit that referenced this pull request Sep 28, 2026
Every row now has a "Fix no framework" column, verified against actual
git log / regression tests in this repo rather than the problem
description alone: a PR/commit reference where a real fix landed, or an
explicit stamp that no framework change resolves it (platform
limitation, by-design behavior, different repo, or site-code
authoring mistake).

Also corrects two stale claims found during verification: matchers ARE
registered by default already (registerBuiltinMatchers() is called
from createSiteSetup()); the pagination-string-coercion fix is PR #394,
not #391. And rewrites the bulk-redirect-table entry in the worker
memory section - it's no longer a manual per-site script, the
framework now natively offloads exact redirect rules to KV
(commit 4ea6df7).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
JonasJesus42 added a commit that referenced this pull request Sep 28, 2026
…562)

## Summary
- Consolidates every documented migration problem (Fresh/Deno → TanStack
Start, and the `@decocms/start` → package-split migration) into a single
validation checklist: `MIGRATION_KNOWN_ISSUES.md`
- Sourced from `CLAUDE.md`,
`.agents/skills/deco-to-tanstack-migration/references/*`,
`.agents/skills/decocms-v6-to-v7-upgrade/`,
`.cursor/skills/deco-server-functions-invoke/`,
`MIGRATION_TOOLING_PLAN.md`, regression tests with historical incident
comments, and persisted memory (VTEX creds, Studio/decofile,
crypto-key-in-CF-Workers, wrangler bindings, NativeWind/image gotchas)
- 12 categories (SSR/hydration, cache, package split, migration-script
tooling, CSS/Tailwind, VTEX/commerce, matchers, HTMX/islands,
CMS/Studio, deploy/secrets, SEO, native-app companion), each item with
symptom / root cause / source / how-to-validate
- Meant to be run against every future site migration as a checklist,
and extended with new findings as they come up

## Test plan
- [ ] Docs-only change, no build/test impact
- [ ] Skim each category once for accuracy against current codebase
state

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Adds `MIGRATION_KNOWN_ISSUES.md`, a consolidated checklist of every
documented migration problem (Fresh/Deno → TanStack Start and the
`@decocms/start` → package-split migration) to run against every future
site migration.

Each item carries a framework-fix status — fixed, partial, or no
framework fix — stamped against real `git log`/regression tests rather
than the problem descriptions. Verification also corrected two stale
claims (matchers are registered by default already; the
pagination-coercion fix is PR #394, not #391) and rewrote the
bulk-redirects entry: exact redirect rules are now offloaded to KV
natively instead of via a per-site script. A dedicated category covers
Cloudflare Worker memory and KV offload, including the fast-deploy
three-piece requirement, the `loadBlocks()` module-scope trap, and
streaming large proxy responses.

Docs-only change, no build or test impact.

<sup>Written for commit 272d8da.
Summary will update on new commits.</sup>

<a href="https://cubic.dev/pr/decocms/blocks/pull/562?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PLP page/pagination props silently pinned to page 1: auto-injected URL params are raw strings, and Number.isFinite doesn't coerce

1 participant