Skip to content

fix(function): pass url into stub-page templates - #939

Merged
Kikobeats merged 1 commit into
masterfrom
cursor/critical-bug-management-7c8d
Sep 20, 2026
Merged

Kikobeats merged 1 commit into
masterfrom
cursor/critical-bug-management-7c8d

Conversation

@cursor

@cursor cursor Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Bug and impact

After extendPage (#937) and passing url into user functions (#935), a snippet that only uses stub page methods plus the request url skipped Chromium and received url: undefined.

Concrete trigger:

async ({ page, url }) => ({
  robots: new URL('/robots.txt', url).href,
  html: await page.html()
})

with extendPage: { html: '<h1>cached</h1>' }. new URL('/robots.txt', undefined) throws, so the function fails. Returning url itself silently produced undefined.

The documented contract is that every function receives the target url. The no-page and full-browser wrappers already forwarded it; the stub-page wrapper did not.

Root cause

packages/function/src/template.js built the stub-page call as { page, response, ...rest }. url is the wrapper's first argument and is stripped from opts before rest is formed, so it never reached the user function.

Fix

Pass url the same way as the other two wrappers: { page, response, ...rest, url } so the target URL wins over any opts.url.

Validation

  • Added template tests for the stub-page path, including opts.url losing to the target URL.
  • Added an extendPage integration test that destructures both page and url with Chromium disabled.
  • ava test/template.js test/extend-page.js: 29 passed.
Open in Web View Automation 

Note

Low Risk
Single-line template fix aligning stub-page behavior with existing wrappers; tests lock in the contract with no auth or data-handling changes.

Overview
Fixes a gap in the stub-page code path (when extendPage stubs satisfy all page usage so Chromium is skipped): user functions now receive the request url in the invocation args, matching the no-page and full-browser wrappers.

The generated wrapper call changes from { page, response, ...rest } to { page, response, ...rest, url }, so the wrapper’s first-argument target URL is available even though it is not part of opts/rest. Target url still wins over opts.url.

Adds template coverage for stub-page url forwarding and precedence, plus an extendPage integration test that destructures { page, url } without starting a browser.

Reviewed by Cursor Bugbot for commit 613fff5. Bugbot is set up for automated code reviews on this repo. Configure here.

extendPage can skip Chromium while the snippet still destructures
url. The no-page and full-browser wrappers already forwarded the
target URL; the stub-page wrapper dropped it, so url was undefined
and new URL(path, url) threw.
@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 66dcc156-fc73-4442-b447-2e5b121d8776

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage is 79.584% — cursor/critical-bug-management-7c8d into master. No base build found for master.

@Kikobeats
Kikobeats marked this pull request as ready for review September 20, 2026 09:17
@Kikobeats
Kikobeats merged commit 5c04d07 into master Sep 20, 2026
25 checks passed
@Kikobeats
Kikobeats deleted the cursor/critical-bug-management-7c8d branch September 20, 2026 09:17
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.

3 participants