Fix 500 in admin password-reset when profile is empty#32
Closed
redscar wants to merge 1 commit into
Closed
Conversation
The `profile` REST arg registered `sanitize_title` directly as its sanitize_callback. WordPress invokes sanitize callbacks as `call_user_func( $cb, $value, $request, $key )`, so the request object landed in sanitize_title's `$fallback_title` parameter. When the input sanitizes to an empty string — as it does for the common `profile: ""` payload — sanitize_title returns the fallback, handing back the WP_REST_Request object. The subsequent `(string)` cast in send_reset() then fataled with "Object of class WP_REST_Request could not be converted to string", surfacing as a 500. Wrap the sanitizer in a closure so only the value reaches sanitize_title. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
redscar
added a commit
that referenced
this pull request
Jun 30, 2026
Add documentation, README/AGENTS, and changelog coverage for the WorkOS-Users-page change-email action and the admin-direct immediate-commit behavior, and bump to 1.0.8. - change-email.md: new "Admin-direct vs. self-service" matrix; admin response shape and 409 on initiate; Users-page surface; admin_changed event; drop the removed admin_bypass setting; test count 13 -> 19. - README.md / AGENTS.md: reflect the new surface, admin-direct path, and admin_changed event. - CHANGELOG.md / readme.txt: 1.0.8 entries for the change-email work (#33) and the password-reset empty-profile 500 fix (#32). - Remove the now-unused change_email_admin_bypass_verification option. - Bump Version / Stable tag / package.json to 1.0.8. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Closing, merged into #33 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The admin password-reset endpoint 500s whenever the
profileparam sanitizes to an empty string — which is the common case, since the UI postsprofile: "". This wraps the sanitizer so it stops handing back the request object.What changed
RestApi.php: wrapped theprofilearg'ssanitize_callbackin a closure so only the value reachessanitize_title.Why
WordPress calls sanitize callbacks as
call_user_func( $cb, $value, $request, $key ). Registeringsanitize_titlebare means the request object lands in its$fallback_titleparameter — andsanitize_titlereturns that fallback whenever the input sanitizes to empty. So an emptyprofilecame back as aWP_REST_Request, and the(string)cast insend_reset()fataled with "Object of class WP_REST_Request could not be converted to string."The closure drops the extra args, so
$fallback_titlekeeps its real default of''and an empty profile resolves to the default login profile as intended.How to test
POST /workos/v1/admin/users/{id}/password-resetwith{"profile":""}against a WorkOS-linked user. Before: 500. After: normal response (reset sent, or a clean error for unlinked users).