You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Server error message is replaced by a generic one when creating a template part, overlay or navigation menu fails #87107
saveEntityRecord( …, { throwOnError: true } ) rethrows what apiFetch rejected with. For a REST API error that is a plain object ({ code, message, data }), not an Error. A few callers check error instanceof Error before reading message, so that check is always false for a REST error and the server's reason is thrown away for a generic message.
For template parts, the check came in with #65390 when the modal moved to TypeScript (before that it read error.message directly). The overlay selector copied the same check.
Affected:
packages/patterns/src/components/create-template-part-modal/index.tsx: always shows "An error occurred while creating the template part."
packages/block-library/src/navigation/edit/overlay-template-part-selector.jsx (creating an overlay from the Navigation block): always shows "An error occurred while creating the overlay."
routes/navigation-list/add-navigation.tsx: shows "Unable to create navigation menu: Unknown error", where "Unknown error" is also not translatable.
routes/guidelines/components/guideline-actions-section.tsx: importing shows "We ran into a problem importing your guidelines: Unknown error" when a save or delete fails on the server.
Step-by-step reproduction instructions
Add this as a mu-plugin to force a REST error:
<?phpadd_filter(
'rest_request_before_callbacks',
function ( $response, $handler, $request ) {
if ( 'POST' === $request->get_method() && str_starts_with( $request->get_route(), '/wp/v2/template-parts' ) ) {
returnnewWP_Error( 'test_error', 'Template parts are read-only on this site.', array( 'status' => 403 ) );
}
return$response;
},
10,
3
);
Go to Appearance > Editor > Patterns.
Click "Add Pattern" and choose "Add Template Part".
Enter a name and click "Add".
Expected: the snackbar says "Template parts are read-only on this site."
Actual: the snackbar says "An error occurred while creating the template part."
The same happens for a real server error, e.g. a user without permission or a failed request.
Activity