Skip to content

[Bug]: issue-quality closes valid reports because extractSection stops at nested sub-headings #541

Description

@SJY051

Client or integration

Other

Area

Other

Summary

The intake bot closed #540 with "Required sections are missing or empty: example usage",
but that section was filled with two concrete examples. The content was lost during parsing,
not missing from the report.

extractSection() in .github/scripts/issue-quality.cjs starts capturing after the target
heading and then breaks on the next line matching /^#{2,4}\s+(.+)/, without comparing heading
depth. When a section begins with a nested sub-heading, capture starts and ends on the very
next line, so the section resolves to an empty string. validateIssue() then reaches the
example !== null && isEmpty(example) branch and pushes "example usage" into emptyCore.
The soft-pass path cannot rescue it because mappedHeadingPresent is true, so the report is
closed as not planned.

The same pattern is matched against raw lines with no fenced-code awareness, so a fenced
example that itself contains a markdown heading terminates the enclosing section the same way.
Reports that paste markdown, docs snippets, or dashboard copy are the most exposed.

Expected: a sub-heading inside a section stays part of that section, and a section ends only
at a heading of the same or shallower depth.

Suggested fix: capture the opening heading's depth from the match and break only when the next
heading's depth is less than or equal to it; optionally skip lines inside fenced blocks while
scanning. This applies to every kind (feature, bug, provider-compatibility), since all of them
resolve their sections through extractSection.

Reproduction

  1. Open a Feature proposal and fill in every required field.
  2. In "Example usage or interface", make the first line a level-3 sub-heading (a line reading
    ### CLI flow), followed by a fenced command block, then a second sub-heading and block.
    Leave no plain text between the section heading and the first sub-heading.
  3. Submit. The Enforce issue quality workflow closes the issue as not planned with
    "Required sections are missing or empty: example usage."
  4. Edit the issue and insert one plain sentence between the section heading and the first
    sub-heading. Change nothing else.
  5. The workflow reruns on the edited event and the bot reopens the issue.

Observed on #540: closed on submission, reopened after adding a single lead sentence. The only
difference between the failing and passing bodies is that one line.

Version

N/A - repository CI. .github/scripts/issue-quality.cjs at af28e37 on main.

Operating system

N/A - GitHub Actions ubuntu-latest runner.

Provider and model

No response

Logs or error output

Issue closed: insufficient detail
Required sections are missing or empty: example usage.

Screenshots and supporting files

No response

Redacted configuration

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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