Skip to content

Launchpad: Reject undeclared keys in the Launchpad endpoint - #55603

Open
paulopmt1 wants to merge 4 commits into
trunkfrom
fix/launchpad-endpoint-undeclared-keys
Open

paulopmt1 wants to merge 4 commits into
trunkfrom
fix/launchpad-endpoint-undeclared-keys

Conversation

@paulopmt1

@paulopmt1 paulopmt1 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes DOTOBRD-777

Proposed changes

  • The Launchpad endpoint (wpcom/v2/launchpad) update handler saved any key found in the JSON request body as a site option, through a default: branch that called update_option() with the key from the request. It now only acts on the keys the route declares.
  • A request whose body has an undeclared key gets a 400 rest_invalid_param naming the key. The check runs before anything is written, so declared keys sent in the same request are not applied either.
  • launchpad_screen was the one declared key that relied on the default: branch. It now has its own case, and its enum validation is unchanged.
  • A request without a JSON body no longer passes null to the loop.

Related product discussion/links

  • DOTOBRD-777

Does this pull request change what data or activity we track or use?

No.

Testing instructions

Unit tests

  • Run jp test php packages/jetpack-mu-wpcom. The new cases are test_update_rejects_undeclared_keys and test_update_with_undeclared_key_changes_nothing in WPCOM_REST_API_V2_Endpoint_Launchpad_Test. They fail on trunk with a 200 and pass on this branch.

On a Simple site

  1. On your sandbox, run bin/jetpack-downloader test jetpack-mu-wpcom-plugin fix/launchpad-endpoint-undeclared-keys.

  2. Sandbox a Simple test site you own, and make sure the sandbox allows writes.

  3. Open the site's wp-admin as its owner, at Settings → General, and note the tagline.

  4. Open the browser console and define a helper:

    const call = ( data ) =>
    	wp.apiFetch( { path: '/wpcom/v2/launchpad', method: 'POST', data } )
    		.then( ( r ) => r )
    		.catch( ( e ) => ( { code: e.code, message: e.message } ) );
  5. Run each request and compare with the expected result:

    Request Expected
    await call( { blogdescription: 'changed' } ) rest_invalid_param, "Invalid parameter(s): blogdescription"
    await call( { launchpad_screen: 'full', blogdescription: 'changed' } ) rest_invalid_param, and launchpad_screen is not changed
    await call( { launchpad_screen: 'skipped' } ) { updated: { launchpad_screen: 'skipped' } }
    await call( { launchpad_screen: 'bogus' } ) rest_invalid_param
    await call( { checklist_statuses: { mobile_app_installed: true } } ) { updated: { checklist_statuses: { mobile_app_installed: true } } }
    await call( { is_checklist_dismissed: { slug: 'build', is_dismissed: true } } ) { updated: [] }, and GET /wpcom/v2/launchpad?checklist_slug=build returns is_dismissed: true
  6. Reload Settings → General and confirm the tagline is the one from step 3.

  7. Undo the test changes: send is_dismissed: false for the checklist, and set launchpad_screen back to its earlier value.

  8. Reset the sandbox with bin/jetpack-downloader reset jetpack-mu-wpcom-plugin --sun (or --moon, whichever it loads from).

On trunk, the first request in step 5 returns { updated: { blogdescription: 'changed' } } and changes the tagline.

Launchpad UI

  • On a site that still shows the classic Launchpad checklist, complete a task and dismiss the checklist from My Home or the wp-admin dashboard widget, reload, and confirm both stick. With the Network tab filtered on launchpad, every write should return 200.

What was run

  • Unit tests: run locally, passing.
  • On a Simple site: steps 1 to 6 and 8 run on a sandboxed test site, with the results in the table.
  • Launchpad UI: not run. The sandboxed test site has Site Setup in place of the classic Launchpad, so there was no checklist to click through.

🤖 Generated with Claude Code

The update handler saved any key in the request body as a site option.
It now returns a 400 when the body has a key the route does not declare,
before writing anything, and handles launchpad_screen explicitly.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (WordPress.com Site Helper), and enable the fix/launchpad-endpoint-undeclared-keys branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack-mu-wpcom-plugin fix/launchpad-endpoint-undeclared-keys

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@jp-launch-control

jp-launch-control Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/jetpack-mu-wpcom/src/features/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-launchpad.php 155/162 (95.68%) 0.28% 0 💚

Full summary · PHP report · JS report

Paulo Trentin and others added 2 commits November 30, 2026 17:23
A JSON body that decodes to a scalar reached array_diff_key() and threw a
TypeError. Treat it as a request with no keys, as before the undeclared-key
check was added.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A dismissal without a slug read a missing key and returned 200 having done
nothing; it now returns a 400. Also fall back to an empty arg list when the
request was not dispatched through the REST server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paulopmt1
paulopmt1 marked this pull request as ready for review November 30, 2026 20:55
@paulopmt1
paulopmt1 requested a review from a team November 30, 2026 20:55
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@markbiek
markbiek self-requested a review November 30, 2026 21:00

@markbiek markbiek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants