Skip to content

Improve friendly error message#1487

Open
cocomarine wants to merge 65 commits into
mainfrom
1448-and-ui-branches-combined
Open

Improve friendly error message#1487
cocomarine wants to merge 65 commits into
mainfrom
1448-and-ui-branches-combined

Conversation

@cocomarine

@cocomarine cocomarine commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

❗ This branch was created by rebasing #1485 to #1483.

How to enable friendly errors

  • editor-standalone (for editor): add friendly_errors_enabled: true to options in src/components/Editor/Project/Project.jsx
  • editor-ui (for http://localhost:3011/web-component.html): add newWebComp.setAttribute("friendly_errors_enabled", "true"); to createWebComponent in src/web-component.html

Decisions made upon adding pfem v. 0.7.0

  • For now, we are showing title and summary of friendly errors (potentially why bit might also be added later on)
  • ErrorMessage now optionally includes FriendlyErrorMessage
  • Moved ErrorMessage to the bottom of input panel above Run button
  • When there are multiple Python files:
    • An error from main.py shows first.
    • When there are errors only in files other than main.py, they will show (one at a time).
    • Whatever error is shown will stay even when you select other tabs within the input panel.

WIP and future pfem

  • More discussion needed in terms of the possibility of adding why of friendly error, copy and UI

Screen recordings of editor with friendly messages

@cocomarine cocomarine temporarily deployed to previews/1487/merge June 3, 2026 08:16 — with GitHub Actions Inactive
@cocomarine cocomarine temporarily deployed to previews/1487/merge June 3, 2026 10:38 — with GitHub Actions Inactive
@cocomarine cocomarine mentioned this pull request Jun 3, 2026
@cocomarine cocomarine temporarily deployed to previews/1487/merge June 3, 2026 12:02 — with GitHub Actions Inactive
…icitly

rawTraceback contains `<exec>` instead of `main.py` as the filename, for example, we can now override the filename passed to friendlyExplain()
@grega grega temporarily deployed to previews/1487/merge June 10, 2026 15:21 — with GitHub Actions Inactive
@cocomarine cocomarine temporarily deployed to previews/1487/merge June 10, 2026 15:33 — with GitHub Actions Inactive
@cocomarine cocomarine temporarily deployed to previews/1487/merge June 10, 2026 15:54 — with GitHub Actions Inactive
PFEM 0.6.0 markup has improved accessibility attributes, such as aria labels and roles.

Has no effect on the styling (since classes, and the markup as a whole, remain the same).
@grega grega temporarily deployed to previews/1487/merge June 10, 2026 17:03 — with GitHub Actions Inactive
@cocomarine cocomarine temporarily deployed to previews/1487/merge June 11, 2026 08:29 — with GitHub Actions Inactive
@cocomarine cocomarine temporarily deployed to previews/1487/merge June 11, 2026 10:45 — with GitHub Actions Inactive
@cocomarine cocomarine temporarily deployed to previews/1487/merge June 11, 2026 11:04 — with GitHub Actions Inactive

Copilot AI left a comment

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.

Pull request overview

Updates the Python error UI to support pfem v0.7.0 “friendly” error messages, and repositions error display so it appears in the input panel (and appropriately in output-only mode), including mobile tab-selection behavior.

Changes:

  • Bumps @raspberrypifoundation/python-friendly-error-messages to 0.7.0 and updates runners to use the new adapter + sections: ["title","summary"].
  • Introduces FriendlyErrorMessage and refactors ErrorMessage styling/markup; moves ErrorMessage rendering into EditorInput.
  • Adds/updates unit + Cypress coverage for friendly errors and mobile error-tab selection.

Reviewed changes

Copilot reviewed 25 out of 28 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.yarnrc.yml Pre-approves the pfem package for Yarn’s restricted installs.
package.json Bumps pfem dependency to 0.7.0.
yarn.lock Lockfile update for pfem 0.7.0.
src/web-component.html Web component test page formatting tweaks and attribute changes.
src/utils/setupTests.js Updates Jest mock exports for pfem adapter changes.
src/PyodideWorker.js Adds rawTraceback to worker error payload for friendlier parsing.
src/components/Mobile/MobileProject/MobileProject.jsx Switches mobile tabs to input when Python errors occur after running.
src/components/Mobile/MobileProject/MobileProject.test.js Adds tests for mobile error display/tab selection.
src/components/Editor/Runners/PythonRunner/SkulptRunner/SkulptRunner.jsx Updates pfem adapter usage and friendlyExplain options; removes runner-local ErrorMessage rendering.
src/components/Editor/Runners/PythonRunner/SkulptRunner/SkulptRunner.test.js Removes outdated error-message placement tests.
src/components/Editor/Runners/PythonRunner/PyodideRunner/PyodideRunner.jsx Updates pfem adapter usage; uses rawTraceback; shows ErrorMessage only in output-only mode.
src/components/Editor/Runners/PythonRunner/PyodideRunner/PyodideRunner.test.js Updates error message expectations and adds friendly-error edge case tests.
src/components/Editor/FriendlyErrorMessage/FriendlyErrorMessage.jsx New component to render sanitized friendly error HTML.
src/components/Editor/FriendlyErrorMessage/FriendlyErrorMessage.test.js New tests for friendly error rendering + sanitization.
src/components/Editor/ErrorMessage/ErrorMessage.jsx Refactors error UI markup; embeds FriendlyErrorMessage and icon.
src/components/Editor/ErrorMessage/ErrorMessage.test.js Updates assertions for new class naming.
src/components/Editor/EditorInput/EditorInput.jsx Renders ErrorMessage at the bottom of the input panel (above Run).
src/components/Editor/EditorInput/EditorInput.test.js Adds a test asserting error message appears in EditorInput.
src/assets/stylesheets/InternalStyles.scss Includes FriendlyErrorMessage styles in internal stylesheet bundle.
src/assets/stylesheets/FriendlyErrorMessage.scss New styling for pfem HTML elements (title/summary/code/file/line).
src/assets/stylesheets/ErrorMessage.scss Updates styling and class structure for new ErrorMessage layout.
src/assets/stylesheets/EditorPanel.scss Formatting/cleanup only.
src/assets/icons/cancel_FILL.svg New icon used in ErrorMessage header row.
src/assets/error_file.svg New asset used to decorate file references in friendly errors.
cypress/helpers/editor.js Updates selectors and adds helper for friendly error message container.
cypress/fixtures/copydeck.json Adds a fixture copydeck for deterministic friendly-error Cypress tests.
cypress/e2e/spec-wc-skulpt.cy.js Adds Cypress coverage for friendly errors in Skulpt.
cypress/e2e/spec-wc-pyodide.cy.js Adds Cypress coverage for friendly errors in Pyodide.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/assets/stylesheets/FriendlyErrorMessage.scss
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@cocomarine cocomarine temporarily deployed to previews/1487/merge June 11, 2026 13:47 — with GitHub Actions Inactive
@cocomarine cocomarine marked this pull request as ready for review June 11, 2026 13:53
@cocomarine cocomarine changed the title Error message UI rebased to 1448 Improve friendly error message Jun 11, 2026
Comment on lines +178 to +180
loadCopydeckFor(navigator.language || "en", {
base: `${process.env.PUBLIC_URL}/python-error-copydecks/`,
});

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.

We normally use locale from the i18n library rather than the navigator language - is this intentional here? I'm not sure if it will cause any problems - does loadCopydeckFor always fall back to en anyway?

Comment thread src/web-component.html
Comment on lines 112 to 119
newWebComp.setAttribute("host_styles", JSON.stringify([]));
const scratchApiEndpoint = new URL(".", window.location.href)
.href
.replace(/\/$/, "");
const scratchApiEndpoint = new URL(
".",
window.location.href,
).href.replace(/\/$/, "");
newWebComp.setAttribute("scratch_api_endpoint", scratchApiEndpoint);

queryParams.forEach((value, key) => {

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.

I don't understand the reasons for these changes and a few others - do you have your linter set up correctly in your editor? Or is there a reason this file wasn't properly linted before?

Just makes it a bit harder to see what you actually have changed

@zetter-rpf zetter-rpf left a comment

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.

Great, I like the tests you've added - clear and easy to see what they are testing.

The PR was harder to review because there are a lot of changes across different files so it's harder for me to see that we're doing everything you said in the PR description - I don't think it's worth splitting out now, but for next time it could be helpful to think about how to break something like this up into logical commits and/or PRs as your working through it.

I added a couple of minor comments, but nothing blocking.

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.

5 participants