Skip to content

[bug] a headless or non-text section heading still reaches wiki.pages.sections and the curator #589

Closed

Description

@cdeust

What happened

ADR-1070 closed the wiki_refine_draft entry point: a section must carry a heading and a body, both non-blank text. Two consumers one layer down make the same assumptions without checking them, and a draft can reach them from another origin (wiki_synthesize, a row written before ADR-1070, a direct DB write).

  1. handlers/wiki_compile.py:155-160 builds the wiki.pages mirror as {section.heading: section.body} with no guard. A headless section lands in the row as the key "". The published Markdown does not have this problem: core/draft_compiler.py:168-173 skips a section with no heading. Demonstrated by the review of PR fix(wiki): a draft section carries a heading and a body, both text (#587) #588 (fix(wiki): a draft section carries a heading and a body, both text (#587) #588 (comment)): a draft holding sections=[{"heading": "", "body": "orphan prose"}] compiles to a .md without the section and to wiki.pages.sections == {"": "orphan prose"}.

  2. core/draft_curator.py:64-66 calls heading.strip() on whatever the section holds. A non-string heading raises AttributeError inside evaluate_draft, the same defect ADR-1070 fixed in _validate_against_contract.

  3. Related, and not covered by ADR-1070: two sections submitted with the same heading are silently deduped by the wiki.pages.sections mapping, so the second body replaces the first without any error.

Expected behavior

A section with no usable heading never reaches wiki.pages.sections, and the curator reports a malformed section instead of raising. Duplicate headings in one draft are refused by name, or the mirror keeps both, decided in the ADR that closes this.

Evidence required to close

Tests compiling a draft whose sections carry a blank heading, a non-string heading and a duplicated heading, asserting what wiki.pages.sections holds afterwards, and a curator test on a non-string heading.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions