Skip to content

Normalize generation error notice messages#562

Merged
dkotter merged 1 commit into
WordPress:developfrom
ekamran:sftq/normalize-error-notices
May 18, 2026
Merged

Normalize generation error notice messages#562
dkotter merged 1 commit into
WordPress:developfrom
ekamran:sftq/normalize-error-notices

Conversation

@ekamran
Copy link
Copy Markdown
Contributor

@ekamran ekamran commented May 17, 2026

What?

This PR normalizes error notice messages in the Excerpt Generation and Content Summarization experiments.

Both features were passing the caught JavaScript Error object directly to createErrorNotice(). They now pass a plain message string instead.

Why?

WordPress notices already identify these notices as errors. Passing the raw Error object caused the visible notice text to include a redundant Error: prefix.

For example, the Excerpt Generation notice previously rendered as:

Error: Content is required to generate an excerpt suggestion.

After this change, it renders as:

Content is required to generate an excerpt suggestion.

This makes the notices cleaner and more consistent with other generation features.

How?

  • Extracts a string message from caught errors before creating the notice.
  • Keeps string errors unchanged.
  • Adds translated fallback messages for unexpected error values.
  • Adds E2E coverage for both affected notice paths.

Testing Instructions

Excerpt Generation

  1. Enable AI.
  2. Enable the Excerpt Generation experiment.
  3. Create a post with no content.
  4. Click Generate excerpt.
  5. Confirm the notice does not include the redundant Error: prefix.

Content Summarization

  1. Enable AI.
  2. Enable the Content Summarization experiment.
  3. Create a post with enough content to enable Generate Summary.
  4. Trigger a failed summary generation request.
  5. Confirm the notice does not include the redundant Error: prefix.

Automated Testing

  • npm run lint:js
  • npm run typecheck
  • npx wp-scripts test-playwright --config tests/e2e/playwright.config.ts tests/e2e/specs/experiments/excerpt-generation.spec.js tests/e2e/specs/experiments/content-summarization.spec.js --project=chromium

Focused E2E result: 12 passed.

Use of AI Tools

AI assistance: Yes
Tool(s): ChatGPT / Codex
Used for: Repository review, implementation guidance, code changes, regression test updates, and local verification. I reviewed the changes, tested the behavior locally, and take responsibility for the final submission.

Open WordPress Playground Preview

@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.21%. Comparing base (19ae2eb) to head (7059e50).

Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #562   +/-   ##
==========================================
  Coverage      71.21%   71.21%           
  Complexity      1151     1151           
==========================================
  Files             67       67           
  Lines           5565     5565           
==========================================
  Hits            3963     3963           
  Misses          1602     1602           
Flag Coverage Δ
unit 71.21% <ø> (ø)

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.

@ekamran
Copy link
Copy Markdown
Contributor Author

ekamran commented May 17, 2026

Screenshots

Excerpt Generation - Before

01-before-excerpt-generation-error-notice

Excerpt Generation - After

02-after-excerpt-generation-error-notice

Content Summarization - Before

03-before-content-summarization-error-notice

Content Summarization - After

04-after-content-summarization-error-notice

@ekamran ekamran marked this pull request as ready for review May 17, 2026 19:35
@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: ekamran <ekamran@git.wordpress.org>

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

@dkotter dkotter added this to the 1.0.0 milestone May 18, 2026
@dkotter dkotter merged commit 8337322 into WordPress:develop May 18, 2026
34 checks passed
@ekamran ekamran deleted the sftq/normalize-error-notices branch May 18, 2026 19:06
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