Skip to content

Editorial Notes: Show an error when a Note fails to save - #1131

Open
maheshbohara wants to merge 3 commits into
WordPress:developfrom
maheshbohara:fix/1130-editorial-notes-failed-save
Open

maheshbohara wants to merge 3 commits into
WordPress:developfrom
maheshbohara:fix/1130-editorial-notes-failed-save

Conversation

@maheshbohara

@maheshbohara maheshbohara commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes #1130

Shows an error notice when Editorial Notes cannot save a Note, in place of the "1 suggestion added" success message.

Why?

createNote() called saveEntityRecord() without throwOnError. When POST /wp/v2/comments failed, the call resolved to undefined and reviewSingleBlock() still returned the number of suggestions. The editor then showed "1 suggestion added. Save to keep changes." in the snackbar and "1 suggestion added, view those Notes here" in the sidebar, with no Note on the post. Steps and editor state are in #1130.

How?

  • createNote() passes { throwOnError: true } to saveEntityRecord(). A failed save now rejects, and the catch blocks that runReview() and reviewBlock() already have show the REST error message as an error notice, the same way they do when the ability request fails.
  • A full review now goes through every block with Promise.allSettled(), so one block that fails no longer stops the run. At the end it shows the count of suggestions that were saved, and one error notice with the number of blocks that failed and the first error message, for example "1 block could not be reviewed: Sorry, you are not allowed to create this comment." This also applies when the ability request fails for a block.
  • When blocks failed and nothing was saved, the sidebar no longer shows "No new suggestions found."
  • A single block review is unchanged: it shows the error.
  • Three e2e tests in editorial-notes.spec.js: a failed save in a full review, a failed save in a single block review, and a full review of two blocks where one save fails and the other is kept. They answer the Note request with a 403.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus
Used for: Investigation, implementation, tests, manual testing, and PR wording. I reviewed the changes and the test results, and I take responsibility for the contribution.

Testing Instructions

  1. Enable the Editorial Notes experiment under Settings > AI, with a provider connected.
  2. Create a post with a paragraph of at least 75 characters and save the draft.
  3. Make the Note save fail. In the browser console on the editor page:
    wp.apiFetch.use( ( options, next ) => {
    	const path = decodeURIComponent( options.path || options.url || '' );
    	if ( options.method === 'POST' && path.includes( '/wp/v2/comments' ) ) {
    		return Promise.reject( {
    			code: 'rest_cannot_create',
    			message: 'Sorry, you are not allowed to create this comment.',
    			data: { status: 403 },
    		} );
    	}
    	return next( options );
    } );
  4. Click "Generate Editorial Notes" in the post sidebar. An error notice reads "1 block could not be reviewed: Sorry, you are not allowed to create this comment." and there is no "suggestion added" message. On develop the snackbar reads "1 suggestion added. Save to keep changes."
  5. Reload the editor, so the snippet is gone, and click the button again. The snackbar reads "1 suggestion added. Save to keep changes." and the Note is in the Notes panel.

I ran these steps on WordPress 7.1.3 (wp-env, PHP 8.3) in Chrome, with the repo's tests/e2e-testing plugin mocking the provider response. With two paragraphs and only the first Note save failing, the snackbar reads "1 suggestion added. Save to keep changes.", the error notice reads "1 block could not be reviewed: Sorry, you are not allowed to create this comment.", and one Note is saved. A single block review with the save failing shows the error only.

Automated:

  • All 15 Editorial Notes e2e tests pass, including the three new ones. Before the review change, the full local run of npm run test:e2e was 194 passed and 7 failed. The 7 are in the alt text, bulk summarization, content classification, markdown feeds and slug generation specs, and they fail the same way on develop without this change in my environment.
  • npm run test:php passes (1793 tests). No PHP changed, so PHP coverage is unchanged.
  • composer lint, PHPStan, npm run typecheck and npm run lint:js pass.

Screenshots or screencast

Before After
Snackbar "1 suggestion added. Save to keep changes." and no Note on the post Error notice "1 block could not be reviewed: Sorry, you are not allowed to create this comment." and no success message

Changelog Entry

Fixed - Editorial Notes: show an error when a Note fails to save, in place of a "suggestions added" message, and keep reviewing the other blocks when one fails.

Open WordPress Playground Preview

createNote() saved the Note without throwOnError, so a failed request resolved to undefined and the review still reported the suggestions as added. The editor showed "1 suggestion added" with no Note behind it.

The save now rejects on failure, and the existing error handling in the full review and the single block review shows the message as an error notice.

See WordPress#1130.
@maheshbohara
maheshbohara requested a review from a team October 7, 2026 08:43
@github-actions

github-actions Bot commented Oct 7, 2026 •

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: maheshbohara <maheshbohara@git.wordpress.org>
Co-authored-by: dkotter <dkotter@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 Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.11%. Comparing base (4fc2d4a) to head (2ec258c).

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #1131   +/-   ##
==========================================
  Coverage      82.11%   82.11%           
  Complexity      3394     3394           
==========================================
  Files            136      136           
  Lines          13178    13178           
==========================================
  Hits           10821    10821           
  Misses          2357     2357           
Flag Coverage Δ
unit 82.11% <ø> (ø)

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

☔ View full report in Codecov by Harness.
📢 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.

}
},
// Reject on a failed save so the caller reports the error.
{ throwOnError: true }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So the big issue here is this feature can be run individually or on the entire post. When run individually, we do want the request to throw an error on failure. But when run on the whole post, if some blocks succeed and then one fails, the entire thing is rejected and an error shows, even though some blocks were processed successfully. Ideally we collect errors and continue until the end (or use something like Promise.allSettled) and then show the proper messaging (errors and success count, if any)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @dkotter, updated in 2ec258c. The full review now uses Promise.allSettled(), so it continues past a failed block and then shows the saved count plus one error notice with the number of blocks that failed. The single block review still shows the error. I added an e2e test for the partial case.

A full review stopped at the first block that failed, so the Notes already saved for other blocks were left without a count and the remaining blocks were never reviewed.

The review now goes through every block, reports the suggestions that were saved, and shows one error notice with the number of blocks that failed. The sidebar no longer says "No new suggestions found." when the only reason is that blocks failed.

See WordPress#1130.
@maheshbohara
maheshbohara requested a review from dkotter October 11, 2026 08:52
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.

Editorial Notes: "N suggestions added" is shown even when the Note failed to save

2 participants