Lint: an unclosed code fence in block prose swallows the rest of the rendered document
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 58/100
Direzione di ricerca
Inizia dal punto di ingresso modelith lint e leggi le regole di lint esistenti e i test basati su fixture. Traccia il modo in cui vengono controllati i campi di prosa a livello di blocco, quindi aggiungi la copertura per un fence non terminato in un campo come /entities/Ticket/definition; il lavoro è completato quando lint segnala il campo e la riga con una severità di warning o errore concordata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Found while reviewing #37. Pre-existing on main, not a regression from that PR — verified byte-identical between a main-built binary and the #37 branch. Filing separately so it doesn't widen that PR.
What happens
A block-level prose field (entity.definition, model.description, enum.description, entity.derivation, scenario.description) may contain a fenced code block. If the author opens a fence and never closes it, everything after it in the rendered .md — later sections, the attributes table, the Mermaid diagram — falls inside the code block.
Repro
kind: DomainModel
version: v1
title: Unclosed fence
description: Probing an unterminated fence in block prose.
entities:
Ticket:
definition: |
An example of the wire format:
```xml
<ticket id="1"/>
attributes:
- name: id
type: string
description: The identifier printed on the ticket.
$ modelith lint fence.modelith.yaml
0 error(s), 0 warning(s)
$ modelith render fence.modelith.yaml --stdout
...
```xml
<ticket id="1"/>
**Attributes**
| Name | Type | Description |
...
**Attributes**, the table and the trailing ```mermaid block are all inside the unterminated fence as far as any Markdown parser is concerned.
Severity
Not a security issue. Fence content is literal even when the fence is unterminated, so the <ticket id="1"/> above is inert — #37's escaping rule is not defeated. The damage is a broken page: on a Docusaurus build the rest of the document renders as code, or the build fails outright.
Lint passes at every severity, which is the real gap — the model is malformed in a way the tool could catch and doesn't.
Why lint and not the renderer
The renderer now uses goldmark (as of #37) to decide what prose is literal. goldmark exposes no "was this fence closed" flag on ast.FencedCodeBlock — an unterminated fence simply runs to the end of the document, which is CommonMark-correct behaviour, not a parser bug. Detecting it inside the renderer means hand-scanning the source again, which is exactly the layer #37 removed.
A lint rule is the right home: it is an authoring mistake, it is cheap to detect (count fence openers per block-level prose field), and lint is where the model's other structural problems are already reported.
Suggested shape
- A semantic warning, or an error — worth deciding, since the rendered output is genuinely broken rather than merely suboptimal.
- Message should name the field and the line, e.g.
/entities/Ticket/definition: code fence opened but never closed — everything after it renders as code. - Fixture-driven test alongside the other lint rules.
Related: #37 (the renderer hardening that surfaced this), ADR-0014 (prose is Markdown, not HTML).
🤖 Filed by Claude Code
- Lingua principale
- Go
- Stelle
- 32
- Fork
- 5
- Merge medio
- 2h 31m
- PR unite (30g)
- 5
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di stacklok/modelith
-
enhancement
Difficoltà 2/5 Mezza giornata Idoneità per principianti 68/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
Tutte le issue di stacklok/modelith
Issue simili
-
nix: vendorHash is outdated Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
Bob Shell support Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
santhosh-tekuri/jsonschema#276 ·