Skip to content

Show the error message when creating a guest author fails - #192

Merged
roborourke merged 1 commit into
developfrom
fix-guest-author-error-message
Oct 19, 2026
Merged

roborourke merged 1 commit into
developfrom
fix-guest-author-error-message

Conversation

@roborourke

Copy link
Copy Markdown
Contributor

Fixes the missing error notice when creating a guest author fails.

#142 changed the catch handler in src/components/AuthorsSelect.tsx to call .json() on the error. But apiFetch rejects with the already-parsed error object, so .json() throws a TypeError. The editor then shows no notice when a user without the create_guest_authors capability tries to create a guest author. Before #142 the message did show.

The handler now uses error.message. It only calls .json() when the rejection is a real Response.

Checked in WordPress Playground (WP 7.1, PHP 8.2), using a mu-plugin that removes create_guest_authors:

With #142, no notice shows:

With #142: no notice shown

With this fix, the notice shows:

With this fix: the error notice shows

With this fix, creating a guest author normally still works:

With this fix: normal guest author creation

Refs #141 and #142.

🤖 Generated with Claude Code

#142 changed the catch handler to call json() on the rejection, assuming apiFetch rejects with a Response. With the default parse option apiFetch rejects with the parsed error object instead, so json() threw a TypeError inside the catch and no notice was shown at all. Before #142 the message did show on WordPress 7.1.

The handler now reads the message from the parsed error, and only calls json() when the rejection really is a Response, which keeps the case #142 was written for.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@roborourke
roborourke merged commit 5475e1d into develop Oct 19, 2026
10 checks passed
@roborourke
roborourke deleted the fix-guest-author-error-message branch October 19, 2026 13:49
@roborourke roborourke mentioned this pull request Oct 19, 2026
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.

2 participants