Skip to content

fix(sectionizer): read bare ancestor labels as section numbers - #142

Open
gajjug004 wants to merge 2 commits into
mainfrom
fix/sectionizer-bare-ancestor-label
Open

gajjug004 wants to merge 2 commits into
mainfrom
fix/sectionizer-bare-ancestor-label

Conversation

@gajjug004

@gajjug004 gajjug004 commented Nov 19, 2026 •

Copy link
Copy Markdown

Problem

Remediation failed on two real manuals (Nephrology, Obstetrics) with TypeError: 'NoneType' object is not subscriptable in _repeats_open_section. The import landed in Review with an empty Wiki tree.

When a sub-section (6.3.3.1) opens before its parent, and no TOC or running header names the parent, ancestor_title falls back to the bare number "6.3.3". The stack marks it numbered, but _section_number used _NUM_RE, which needs text after the number, so it returned None.

Fix

_section_number now also reads a bare dotted number.

Tests

  • New regression test fails before the fix and passes after.
  • test_sectionize: 77 passed. Full app suite passes.
  • Both manuals rebuild: 204 and 96 sections.

Screenshots

Before (Obstetrics import, Wiki tab)

before-00005.png

After

after-00005.png

CI

Frappe develop now requires a tree node's parent to be a group (frappe/frappe@10c5427c51). create_section added a child under a leaf and set is_group only afterwards, so test_sync_group_needs_regenerate_when_child_missing_wiki failed on main too. It now marks the parent as a group before the insert. The full suite (591 tests) passes locally with that frappe commit applied.

ancestor_title names a group the body never titled by its bare
number ("6.3.3"). _section_number could not parse it, so any stack
lookup on that group raised TypeError and remediation failed with
an empty section tree.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

Frappe now rejects a tree node whose parent is not a group
(frappe/frappe@10c5427c51). create_section inserted a child
under a leaf and relied on _rebuild_tree to set is_group
afterwards, so the insert failed with "must be a group node".

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

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