Skip to content

fix: improve body parsing logic - #72

Merged
gr2m merged 5 commits into
stefanbuck:mainfrom
Ansuel:(metal-gear-)solid-parsing
Apr 22, 2026
Merged

fix: improve body parsing logic#72
gr2m merged 5 commits into
stefanbuck:mainfrom
Ansuel:(metal-gear-)solid-parsing

Conversation

@Ansuel

Copy link
Copy Markdown
Contributor

Current body parsing logic with trim() + split("###") is too fragile and
pose problems with some body that contains case with ### in the middle
of the line or case with codeblock ``` section.

These case will cause the script to parse these as separate section and
produce wrong outputs and in some case even prints error assuming things
are checkbox and errors out on the concat function.

To make the parsing logic more solid, implement a dedicated function and
parse with this logic:

  • We split the body for "\n"
  • We ignore codeblock ``` section
  • We check "###" only at the start of the line
  • We check for "### " (with the space included) as that is the correct
    section Github issue template expects.

With the following change case like:

root@OpenWrt:~# cat /boot/config.txt

Are correctly parsed as all part of a single section instead of being
wrongly treated as different empty sections.

Signed-off-by: Christian Marangi ansuelsmth@gmail.com

@Ansuel

Copy link
Copy Markdown
ContributorAuthor

Discovered by this openwrt/openwrt#15265

Made further research and found the root of the problem!

@Ansuel
Ansuelforce-pushed the (metal-gear-)solid-parsing branch from 20e3584 to 7b837e5CompareApril 26, 2024 17:26
Comment threadindex.js Outdated
@Ansuel
Ansuelforce-pushed the (metal-gear-)solid-parsing branch 2 times, most recently from 14c673f to 06dd03dCompareJanuary 31, 2025 12:55
@Ansuel

Copy link
Copy Markdown
ContributorAuthor

@jamacku sorry for the delay... I fixed the comment and also add an additional test to catch this special case. We check now if line start with ``` directly.

@jamackujamacku left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, Thank you.

@stefanbuck

Copy link
Copy Markdown
Owner

Awesome, good stuff. I will have a closer look shortly and then cut a new major version for this change.

Ansueland others added 5 commits April 22, 2026 07:50
Current body parsing logic with trim() + split("###") is too fragile and
pose problems with some body that contains case with ### in the middle
of the line or case with codeblock ``` section.
These case will cause the script to parse these as separate section and
produce wrong outputs and in some case even prints error assuming things
are checkbox and errors out on the concat function.
To make the parsing logic more solid, implement a dedicated function and
parse with this logic:
- We split the body for "\n"
- We ignore codeblock ``` section
- We check "###" only at the start of the line
- We check for "### " (with the space included) as that is the correct
section Github issue template expects.
With the following change case like:
```
root@OpenWrt:~# cat /boot/config.txt
```
Are correctly parsed as all part of a single section instead of being
wrongly treated as different empty sections.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Add additional test for section with #### to prevent and catch in
future code change that would produce wrong parsing.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Add test for codeblock ``` ignore to prevent and catch in future code
change that would produce wrong parsing.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Add test for codeblock ```sh ignore to prevent and catch in future code
change that would produce wrong parsing.
This is a variant of the ``` test that makes the code block section
target specific code.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
The fixtures and test blocks added in this PR used CommonJS
(require / module.exports). After rebasing onto main, which
converted the codebase to ESM in stefanbuck#105, they need to use
import / export default and the loadJson helper.
@gr2m
gr2mforce-pushed the (metal-gear-)solid-parsing branch from 06dd03d to daac19fCompareApril 22, 2026 14:52
@gr2mgr2m changed the title feat: improve body parsing logicfix: improve body parsing logicApr 22, 2026
@gr2m

gr2m commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator

Gonna merge as fix. No breaking changes are introduced. Thanks @Ansuel!

@gr2m
gr2m merged commit cf55537 into stefanbuck:mainApr 22, 2026
1 check passed
release-app-github-issue-parserBot pushed a commit that referenced this pull request Apr 22, 2026
## [3.2.5](v3.2.4...v3.2.5) (2026-04-22)
### Bug Fixes
* improve body parsing logic ([#72](#72)) ([cf55537](cf55537))
@release-app-github-issue-parser

Copy link
Copy Markdown

🎉 This PR is included in version 3.2.5 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@Ansuel

Copy link
Copy Markdown
ContributorAuthor

@gr2m thanks a lot!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Ansuel@stefanbuck@gr2m@jamacku