GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — id(web): prosemirror_to_markdown panics on misplaced nodes — json_to_ast never validates block/inline placement · Issue #1043 · developing-today/code

id(web): prosemirror_to_markdown panics on misplaced nodes — json_to_ast never validates block/inline placement #1043

New issue
Copy link
New issue
Copy link
Closed
#1089
Closed
id(web): prosemirror_to_markdown panics on misplaced nodes — json_to_ast never validates block/inline placement#1043
#1089
Copy link
Assignees
dezren39
Labels
app/idPackage/app: id (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

Description

@dezren39
dezren39
opened on Oct 27, 2026
Issue body actions

Bug

prosemirror_to_markdown (pkgs/id/src/web/markdown.rs:908) does not validate the placement of nodes in the incoming ProseMirror document. json_to_ast (markdown.rs:963) recursively appends children without checking that inline nodes only appear in inline contexts and block nodes only in block contexts, so a structurally misplaced node produces an ill-formed comrak AST:

  • In debug builds, comrak's format_commonmark validation panics: The document to format is ill-formed: InvalidChildType { parent: Document, child: Text("orphan") } (comrak 0.56 cm.rs:29).
  • In release builds the validation is compiled out (#[cfg(debug_assertions)]), so the same input silently emits invalid markdown instead of returning an error.

The function's contract is Result<String, ConversionError> — an unknown node type already returns ConversionError::UnknownType (markdown.rs:1186). A known node in an impossible position should be an error (or a documented coercion), never a panic / silent corruption. The save path is convert_doc_to_bytes in pkgs/id/src/web/routes.rs:1986, so a malformed stored/imported/collab document hits this on save or export.

Evidence (verified 2026-10-26 on main cf60812)

Standalone probe crate carrying a verbatim copy of src/web/markdown.rs (comrak 0.56.0 locked) — logs in goal hidden_files probe-2026-10-26-2145/out3.log + out4.log. Each of these prosemirror_to_markdown inputs panics at comrak cm.rs:29:

  1. doc with a top-level text node: {"type":"doc","content":[{"type":"text","text":"orphan"}]} → InvalidChildType { parent: Document, child: Text("orphan") }
  2. doc with a top-level image node (inline node at block level)
  3. doc with a top-level hard_break node
  4. a paragraph whose content contains a paragraph

Controls that behave correctly today: unknown node type → Err(UnknownType("mention")); heading level 9 → clamped to 6; empty doc → Ok("").

Related precedent: #1017 (table-cell special case built an ill-formed AST that panicked in the same comrak validation) — fixed by making the conversion produce a well-formed AST. This issue is the general case: no placement validation anywhere in json_to_ast.

Why it matters

Stored ProseMirror documents are not exclusively editor-produced: they arrive via import, the collab layer, older clients, and direct API writes. Any of those can carry a misplaced node; today that means a panicked handler in debug builds and silently invalid .md output in release builds, on a function whose signature promises a ConversionError.

Acceptance criteria

  • prosemirror_to_markdown never panics and never emits an ill-formed AST for the four shapes above; each returns Err(ConversionError::…) (new variant if needed) or a documented, tested coercion (e.g. wrapping stray inline nodes in a paragraph).
  • Regression tests in web::markdown covering: inline node at doc level (text/image/hard_break), block node inside a paragraph, and at least one misplaced-node case inside a list item / blockquote / table cell.
  • Existing web::markdown tests still pass; well-formed documents render byte-identically to before.

Activity

Next
  1. developing-today commented on Oct 27, 2026

    @developing-today
    developing-todayBot
    on Oct 27, 2026 – with developing.today
    Contributor
    More actions

    CODE-188

  2. github-actions
    assigned
    dezren39
    on Oct 27, 2026
  3. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    status/needs-triageNot yet triaged; needs a first look
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    queue/queuedHas a queued queue task
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    on Oct 27, 2026
  4. dezren39 commented on Oct 27, 2026

    @dezren39
    dezren39
    on Oct 27, 2026
    MemberAuthor
    More actions

    🤖 Agent note · filed

    • Agent: new-issue-creator job
    • Session / ID: new-issue-creator cron run 2026-10-26 21:45 CDT
    • Found via: filed this run
    • Task: Verified with a standalone probe crate carrying a verbatim copy of src/web/markdown.rs (comrak 0.56.0) on main cf60812 (logs hidden_files/probe-2026-10-26-2145/out3.log + out4.log): prosemirror_to_markdown panics at comrak cm.rs:29 (ill-formed AST, InvalidChildType) for a doc with a top-level text/image/hard_break node and for a paragraph containing a paragraph; json_to_ast (markdown.rs:963) does no block/inline placement validation, while unknown node types already return ConversionError::UnknownType (:1186). Release builds skip comrak's debug-only validation and silently emit invalid markdown. Enqueued as a triage packet to repo-health-code-pilot — error-vs-coerce is a design choice for triage (cf. id(web): saving a table cell with a hard break or a list panics in the markdown codec — ill-formed comrak AST #1017, the table-cell special case of the same class).
    • Expectation: triage decides error vs coercion; done when the four shapes return a ConversionError (or documented coercion) with regression tests and no panic.
    • Links: probe evidence in goal hidden_files (see issue body)
  5. dezren39
    added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    and removed
    status/needs-triageNot yet triaged; needs a first look
    queue/queuedHas a queued queue task
    on Oct 27, 2026
  6. 11 remaining items

  7. developing-today
    added
    status:in-review
    on Oct 27, 2026
  8. dezren39
    added a commit that references this issue on Oct 27, 2026

    style(id-web): rustfmt placement_of match arms (#1043)

    f6594ee
  9. dezren39
    added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    on Oct 27, 2026
  10. dezren39 commented on Oct 27, 2026

    @dezren39
    dezren39
    on Oct 27, 2026
    MemberAuthor
    More actions

    Parked — PR #1089 opened @ f6594ee (placement validation + MisplacedNode; rustfmt fix included after the first CI run flagged formatting). Probe suite 71/71, all five panic shapes now return Err.

    {"v":1,"kind":"note","state":"parked","task_id":1232,"summary":"PR 1089: validate_placement walk + ConversionError::MisplacedNode; verified in verbatim-codec probe (71/71, five shapes Err, controls unchanged). Parked 20m on CI per the 5-minute rule.","artifacts":["https://github.com/developing-today/code/pull/1089"],"next":"merge PR 1089 when CI green, then complete task 1232"}
    
  11. dezren39
    closed this as completedin #1089on Oct 27, 2026
  12. dezren39
    added a commit that references this issue on Oct 27, 2026

    Merge pull request #1089 from developing-today/queue/1232-1043-placem…

    a2e7bfc
  13. developing-today
    added
    status:done
    and removed
    status:in-review
    on Oct 27, 2026
  14. dezren39 commented on Oct 27, 2026

    @dezren39
    dezren39
    on Oct 27, 2026
    MemberAuthor
    More actions

    Done — queue worker (Lane A), task 1232: PR #1089 merged (merge commit a2e7bfc), issue auto-closed. CI on f6594ee: every functional check green (test-unit, all shards, cargo-check, fmt, treefmt, web suites); the only failures were clippy-lint and its aggregate, both Magic Nix Cache HTTP 418 / GitHub Actions Cache rate-limit infra (no clippy findings in the log) — merged under the standing rule for verified changes with unrelated infra failures, with the local probe suite at 71/71 from the previous shift.

    {"v":1,"kind":"note","state":"done","task_id":1232,"summary":"PR 1089 merged a2e7bfc9; #1043 auto-closed. CI green except clippy/aggregate failing on Magic Nix Cache 418 infra (no lint findings). Probe suite 71/71 (prior shift).","artifacts":["https://github.com/developing-today/code/pull/1089"],"next":"none — task 1232 complete"}
    
  15. dezren39
    removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dezren39
    dezren39

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.