Skip to content

Editor: show block errors instead of silently suppressing the save button - #2353

Open
krobipd wants to merge 5 commits into
ioBroker:masterfrom
krobipd:harden-blockly-save-errors
Open

Editor: show block errors instead of silently suppressing the save button#2353
krobipd wants to merge 5 commits into
ioBroker:masterfrom
krobipd:harden-blockly-save-errors

Conversation

@krobipd

@krobipd krobipd commented Aug 18, 2026

Copy link
Copy Markdown

Builds on #2352 and contains its commits, because both change the same built editor files in admin/. Once #2352 is merged, this PR reduces to its own last commit — reviewing that commit alone is enough.

What users see

Every wave of "Blockly scripts cannot be saved anymore" reports (#487 in 2020, #1891 in the 9.0.x line, #2349 now) shares the same experience: the save button simply never appears, and nothing anywhere tells the user why. The reason is always some block throwing while the editor regenerates the script — but the only trace is a stack trace in the browser console, which most reporters never open ("Is it really so hard to press F12???" — that question from #1891 answers itself: for most users, yes).

Why it happens

The editor offers Save only after a change has been regenerated: workspaceToCode plus Xml.workspaceToDom (the workspace XML travels as a base64 comment behind the code). A block that throws inside that chain kills the change handler, and with it the save button — silently. #2352 fixes the two blocks that currently throw, but the next Blockly upgrade or block bug will hide exactly the same way again.

The change

  • The change handler catches the error and shows it in the editor's existing error dialog — once per distinct error, not again on every further change while the script stays broken. The console still gets the full stack trace.
  • A failing export (same serialization, triggered from the menu) shows its error too, instead of doing nothing at all.
  • The two new texts are translated in all 11 languages.

Saving stays blocked while a block is broken — that is correct, because the generated code would be broken too. The difference is that the user now sees which error stands between them and saving, and the next #2349 becomes a precise bug report instead of a wave of "cannot save" issues.

Verified

  • npm run lint, npm run test:package, npm run test:blockly, npm run build, npm test (declarations + integration, 280 passing) locally on Node 22
  • ✅ The rebuilt editor bundle contains the new dialog text; the error path reuses the existing DialogError mechanism (same as import errors)

🤖 Generated with Claude Code

krobipd and others added 5 commits August 18, 2026 22:25
The timer and schedule blocks answer getVarModels() with hand-built
variable models in the Blockly 11 shape ({ getId, name, type }).
Blockly 13 reads variable models through methods - Xml.variablesToDom
calls getName()/getType() while the workspace is serialized for saving -
so every save of a script containing such a block threw
'getName is not a function'. The editor's change handler died on that,
and with it the save button (ioBroker#2349).

The models now carry the methods; the bare properties stay for adapter
block files written against the Blockly 11 shape.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
With 'statements' unchecked in the function's mutator dialog the
mutation removes the STACK input, and statementToCode() throws for a
missing input - the same trap the RETURN input is already guarded
against one line below. The throw suppressed the save button for every
script containing such a function (ioBroker#1958).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The snapshots only exercise workspaceToCode, but the editor saves with
workspaceToCode PLUS Xml.workspaceToDom - the workspace XML travels as
a base64 comment behind the generated code. A block whose serialization
throws suppresses the save button without any snapshot moving, which is
exactly how the timer blocks' variable models broke under Blockly 13.

Every corpus entry is now saved the way the editor does it and the
saved XML reloaded to the same code. A new fixture covers the function
with a return value and no statements, whose generator branch the
toolbox (statements on by default) could never reach.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… button

The editor only offers Save after it has regenerated the script
(workspaceToCode plus Xml.workspaceToDom). A block that throws in that
chain used to kill the change handler silently: no save button, no
message, only the browser console said why. That is how ioBroker#2349 and ioBroker#1958
stayed invisible to their reporters - and how the next broken block
will hide again.

The change handler now catches the error and shows it in the editor's
error dialog, once per distinct error rather than on every further
change while the script stays broken. A failing export (same
serialization, triggered from the menu) shows its error too instead of
doing nothing. Translations added in all 11 languages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant