Skip to content

A refused Apply or structure insert says which node cannot be read, and why - #656

Merged
MerciHanrim merged 1 commit into
mainfrom
register-refusal-names-cause
Nov 23, 2026
Merged

MerciHanrim merged 1 commit into
mainfrom
register-refusal-names-cause

Conversation

@MerciHanrim

Copy link
Copy Markdown
Owner

Part of #619 (item 5, the last item; the revision export and data import messages are left as a follow-up, see below).

What was wrong

A hand-edited or damaged file can hold a model node that cannot be read. Opening keeps such a node as written; the editor cannot write one, since the Register field commits only text that parses. Measured on main 8e4c5b02:

Case What the projection throws The reason a refusal gave
Register expr 42 … node r (register): expr is not a string "A node or edge holds a non-finite number (NaN / Infinity)."
Register expr 1 + … node r (register): expr does not parse: "1 +" the same
Parameter value "abc" … node p (parameter): value is not a number the same
Pool initial Infinity (control) … node inf data.initial the same, correct here

Two catches dropped the cause: validateResultGraph, which selective Apply and the data import commit use, and the structure insert's backstop. The error's own message also began "non-finite number in revision content at" for every cause but an unknown kind.

The change

  • InvalidRevisionContentError carries contentCause, a field named so as not to shadow the standard Error.cause:

    • a non-finite number and where it is;
    • a model node that cannot be read, with the reader's own reason;
    • a model node in a version 1 document;
    • an unknown kind;
    • an internal invariant.

    Its message now says that cause.

  • invalidContentReason(e) gives the refusal reason in model-layer English, like the other reasons:

    • a model node: "Node r (register) cannot be read: expr does not parse: "1 +".";
    • a genuine non-finite number: the existing sentence plus where it is, "A node or edge holds a non-finite number (NaN / Infinity): node inf data.initial.".

    It holds no stack and no error class name.

  • validateResultGraph and insertGraph's backstop use it.

  • An error of another class keeps the old sentence, as before.

Where it shows:

  • Review shows a selective Apply's reasons verbatim, so it now names the node.
  • The structure insert's alert shows its reason, so it does too.

Left out, as agreed: a follow-up

  • The revision export keeps "This diagram has content that cannot be exported, such as a number that is not finite. Nothing was exported."
  • The data import keeps "The resulting graph is invalid — please contact support."

Naming the node there needs a new catalog key in every language. It will be listed on #619 as a separate scope. (The data import's internal detail.reasons now carries the new reason, but the wizard does not show it.)

Tests (src/model/invalidContentReason.test.ts), written first

Each of the four cases checks the thrown message, validateResultGraph's reasons and insertGraph's reason:

  • the three malformed model values;
  • the Infinity control, which keeps its sentence and gains where it is.

A fifth test checks that no reason holds a stack frame, a file name or an error class name.

On main's code the four case tests fail and the fifth passes. For the control, only the reason fails: the message was already right. With the change all five pass.

Checks

  • npx tsc -b: clean.
  • npm run lint: 88 warnings, the baseline.
  • All check:* scripts: pass.
  • Unit suite: 5758 passed, 4 skipped.
  • Related e2e, one worker, no retries: e2e/module-system.spec.ts and e2e/revision.spec.ts, 40 passed. They hold no screenshot comparisons.

What it touches

  • The reason text of a refused selective Apply and structure insert, only for content the projection cannot read.
  • The error's message, which the open revision's changed-mark check writes to the console.
  • What is refused is unchanged, and so are the revision export and data import messages.

…nd why

InvalidRevisionContentError carries its cause (a non-finite number and where, an unreadable model node with the reader's reason, a model node in a version 1 document, an unknown kind) and a message for it. validateResultGraph and the structure insert's backstop give that reason instead of the non-finite sentence for every cause. Part of #619.
@MerciHanrim MerciHanrim added the bug Something isn't working label Nov 23, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying cozy-loop-studio with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0e356e8
Status: ✅  Deploy successful!
Preview URL: https://c86521f8.cozy-loop-studio.pages.dev
Branch Preview URL: https://register-refusal-names-cause.cozy-loop-studio.pages.dev

View logs

@MerciHanrim
MerciHanrim merged commit fde07d8 into main Nov 23, 2026
13 checks passed
@MerciHanrim
MerciHanrim deleted the register-refusal-names-cause branch November 23, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant