Skip to content

fix: correctly serve ISR pages with trailing slash set to 'always' - #5

Open
anurag6569201 wants to merge 1 commit into
qa/agent-sveltejs-kit/pr-05-16903/basefrom
qa/agent-sveltejs-kit/pr-05-16903/head
Open

anurag6569201 wants to merge 1 commit into
qa/agent-sveltejs-kit/pr-05-16903/basefrom
qa/agent-sveltejs-kit/pr-05-16903/head

Conversation

@anurag6569201

Copy link
Copy Markdown

Fixed sveltejs#12556


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

Source merge-base: 0544d5f13686bd5e6f6daa5f074b064990134833
Source head: 8ab1c3eafee04b2d06867377a7805e828e4754e0

@shipwright-agent

Copy link
Copy Markdown

⛔ Shipwright · Blocked

Recommendation: do not merge PR #5 · Tier T3
Checks: 0 total · 0 needing attention

Next step: resolve the blocking findings before merge.

Findings (7)

  • CRITICAL The new static ISR route insertion assumes static_config.routes always contains a route with handle === 'filesystem'. · packages/adapter-vercel/index.js:332
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • CRITICAL The ISR pathname is now taken directly from the route regex capture group and assigned to url.pathname without normalization. · packages/adapter-vercel/files/serverless.js:22
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • CRITICAL The workflow change exposes VERCEL_TOKEN and VERCEL_ORG_ID as environment variables and also interpolates VERCEL_TOKEN directly into the command line. · .github/workflows/platform-tests-vercel.yml:43
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The new static_isr_routes array is typed as any[] and the routing logic branches on route.segments.some((segment) => segment.dynamic) with no explanation of why static and dynamic · packages/adapter-vercel/index.js:233
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The test only asserts the generated config for one static ISR route and one dynamic ISR route. · packages/adapter-vercel/test/apps/basic/build.test.js:47
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The CDN cache purge runs unconditionally before the platform test and uses --yes. · .github/workflows/platform-tests-vercel.yml:44
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The route destination is built by interpolating src-derived pathname into a query string without URL-encoding. · packages/adapter-vercel/index.js:274
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

Fireworks usage: 15,108 input · 806 output · 15,914 total tokens · $0.0039 · 13s · 0 fix iteration(s)

Open the Shipwright check for full evidence and the audit bundle. Use /shipwright rerun to verify again.

}
}

const filesystem = static_config.routes.findIndex((route) => route.handle === 'filesystem');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · CRITICAL

The new static ISR route insertion assumes static_config.routes always contains a route with handle === 'filesystem'.

Impact: The new static ISR route insertion assumes static_config.routes always contains a route with handle === 'filesystem'. If that route is absent, findIndex returns -1 and splice(-1, 0, ...static_isr_routes) inserts before the last route instead of before the filesystem phase, silently breaking routing order for static ISR routes.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

// as a search parameter, so we need to extract it
const url = new URL(request.url);
let pathname = url.searchParams.get('__pathname');
const pathname = url.searchParams.get('__pathname');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · CRITICAL

The ISR pathname is now taken directly from the route regex capture group and assigned to url.pathname without normalization.

Impact: The ISR pathname is now taken directly from the route regex capture group and assigned to url.pathname without normalization. Previously the code collapsed repeated slashes and reconstructed the data suffix. With optional/rest route patterns, the captured value can contain empty or repeated slash segments, producing malformed pathnames such as /foo//bar or losing the __data.json suffix behavior, which can cause fals…

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}

# avoid stale cache results when testing ISR routes

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · CRITICAL

The workflow change exposes VERCEL_TOKEN and VERCEL_ORG_ID as environment variables and also interpolates VERCEL_TOKEN directly into the command line.

Impact: The workflow change exposes VERCEL_TOKEN and VERCEL_ORG_ID as environment variables and also interpolates VERCEL_TOKEN directly into the command line. The token is already available as a secret in the step, so the explicit env block and inline --token interpolation increase the risk of accidental logging or command-line disclosure. Use the existing vercel-action secret handling or pass the token via stdin/env withou…

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

});
}

// Vercel's filesystem phase serves a function at its own path, with or without a

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · HIGH

The new static_isr_routes array is typed as any[] and the routing logic branches on route.segments.some((segment) => segment.dynamic) with no explanation of why static and dynamic

Impact: The new static_isr_routes array is typed as any[] and the routing logic branches on route.segments.some((segment) => segment.dynamic) with no explanation of why static and dynamic ISR routes must be ordered differently. A future maintainer cannot tell from the code why static routes must precede filesystem while dynamic routes must follow it.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

test('__data.json function exists in Vercel routing configuration', () => {
assert.ok(isr_page_route_sources.some((src) => src.includes('__data.json')));
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · HIGH

The test only asserts the generated config for one static ISR route and one dynamic ISR route.

Impact: The test only asserts the generated config for one static ISR route and one dynamic ISR route. It does not cover optional parameters, rest parameters, or routes with multiple dynamic segments, which are exactly the cases where the removed get_pathname and regex normalization logic previously prevented malformed __pathname values.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}

# avoid stale cache results when testing ISR routes
- name: Purge Vercel CDN Cache

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · HIGH

The CDN cache purge runs unconditionally before the platform test and uses --yes.

Impact: The CDN cache purge runs unconditionally before the platform test and uses --yes. If VERCEL_PROJECT_ID_BASIC is unset or wrong, the purge may target the wrong project or fail in a way that leaves stale cache entries, causing flaky ISR tests that are hard to diagnose.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

}

const q = `?__pathname=/${pathname}`;
const routes = route.segments.some((segment) => segment.dynamic)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · HIGH

The route destination is built by interpolating src-derived pathname into a query string without URL-encoding.

Impact: The route destination is built by interpolating src-derived pathname into a query string without URL-encoding. If a route pattern contains characters that are special in query strings, the generated __pathname parameter can be malformed or allow query-parameter injection into the ISR function request.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

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