Skip to content

Fix connector approval dismiss for keys containing slashes#615

Merged
dkotter merged 2 commits into
WordPress:developfrom
t-hamano:fix/connector-approval-dismiss-encoded-slash
May 26, 2026
Merged

Fix connector approval dismiss for keys containing slashes#615
dkotter merged 2 commits into
WordPress:developfrom
t-hamano:fix/connector-approval-dismiss-encoded-slash

Conversation

@t-hamano

@t-hamano t-hamano commented May 23, 2026

Copy link
Copy Markdown
Contributor

What?

Fix the Dismiss button on the Connector Approvals settings page, which failed with Failed to dismiss request.

Recording.2026-05-23.160520.mp4

Why?

The dismiss key is a composite of the caller basename and connector ID (example: wp-json/ai/v1/connector-approvals/pending/ai%2Fai.php%3A%3Agoogle), so it contains a slash. The frontend sent it as a URL path segment. WordPress decodes the encoded slash (%2F) back to / before REST route matching, so the route pattern (?P<key>[^/]+) no longer matched and the request returned rest_no_route (404).

The Approve action was unaffected because it already sends its identifier in the request body, not in the path.

How?

Send the key as a query argument instead of a path segment. Query arguments are decoded as plain values and never take part in path-based route matching, so dismiss works regardless of web server configuration.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 4.7
Used for: Diagnosing the encoded-slash route-matching failure and implementing the fix. Reviewed and verified by me (tsc, ESLint, and PHPUnit all pass).

Testing Instructions

  1. Create a pending approval request from a plugin.
  2. On the Connector Approvals settings page, click Dismiss on that pending request.
    • Before: shows Failed to dismiss request.
    • After: the pending request is removed and the list updates.

Changelog Entry

Fixed - Connector Approvals "Dismiss" button failing for pending requests whose key contains a slash.

Open WordPress Playground Preview
t-hamano and others added 2 commits May 23, 2026 16:32
The Dismiss button on the Connector Approvals page failed with
"Failed to dismiss request." for any pending entry whose key contains
a slash (e.g. `plugin/plugin.php::connector`).

The composite key was sent as a URL path segment. WordPress decodes the
encoded slash (%2F) back to `/` before REST route matching, so the
`(?P<key>[^/]+)` pattern stopped matching and the request 404'd (Apache
also rejects %2F-containing paths by default).

Pass the key as a query argument instead: it is decoded as a plain value
and never participates in path-based route matching, so it works
regardless of web server config. Drop the now-redundant rawurldecode()
because query args arrive already decoded.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The dismiss route changed from a path parameter
(`/connector-approvals/pending/(?P<key>[^/]+)`) to a static path
(`/connector-approvals/pending`) with the key sent as a query argument,
so the route-registration assertions must expect the new path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@t-hamano t-hamano marked this pull request as ready for review May 23, 2026 07:52
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov

codecov Bot commented May 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.18%. Comparing base (246680c) to head (f13c461).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #615   +/-   ##
==========================================
  Coverage      73.18%   73.18%           
  Complexity      1731     1731           
==========================================
  Files             85       85           
  Lines           7473     7473           
==========================================
  Hits            5469     5469           
  Misses          2004     2004           
Flag Coverage Δ
unit 73.18% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@dkotter dkotter added this to the 1.1.0 milestone May 26, 2026
@dkotter dkotter merged commit 0e46b65 into WordPress:develop May 26, 2026
21 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants