compliance-trestle
compliance-trestle copied to clipboard
trestle author profile-assemble `IndexError: string index out of range` while processing markdown
Describe the bug
Running trestle author profile-assemble
causes IndexError
. This issue came up after the update to version 2.1.0
. The same command exits with code 0
on trestle version 2.0.0
trestle author profile-assemble -v \
--markdown "md_dir/profile" \
--output profile \
--set-parameters
Error Log:
trestle.core.commands.author.profile:96 ERROR: Assembly of markdown to profile failed: string index out of range
Traceback (most recent call last):
File "~/venv/lib/python3.10/site-packages/trestle/core/commands/author/profile.py", line 190, in _run
return self.assemble_profile(
File "~/venv/lib/python3.10/site-packages/trestle/core/commands/author/profile.py", line 349, in assemble_profile
found_alters, param_dict, param_map = catalog_api.read_additional_content_from_md(label_as_key=True)
File "~/venv/lib/python3.10/site-packages/trestle/core/catalog/catalog_api.py", line 106, in read_additional_content_from_md
return self._reader.read_additional_content(
File "~/venv/lib/python3.10/site-packages/trestle/core/catalog/catalog_reader.py", line 65, in read_additional_content
sort_id, control_alters, control_param_dict = ControlReader.read_editable_content(
File "~/venv/lib/python3.10/site-packages/trestle/core/control_reader.py", line 359, in read_editable_content
yaml_header, control_tree = md_api.processor.process_control_markdown(control_path, cli_section_dict, part_label_to_id_map) # noqa: E501
File "~/venv/lib/python3.10/site-packages/trestle/core/markdown/markdown_processor.py", line 86, in process_control_markdown
tree = ControlMarkdownNode.build_tree_from_markdown(lines)
File "~/venv/lib/python3.10/site-packages/trestle/core/markdown/base_markdown_node.py", line 61, in build_tree_from_markdown
ob, _ = ob._build_tree(lines, 'root', 0, start_level)
File "~/venv/lib/python3.10/site-packages/trestle/core/markdown/control_markdown_node.py", line 188, in _build_tree
subtree, i = self._build_tree(lines, line, i + 1, level + 1, part_id)
File "~/venv/lib/python3.10/site-packages/trestle/core/markdown/control_markdown_node.py", line 188, in _build_tree
subtree, i = self._build_tree(lines, line, i + 1, level + 1, part_id)
File "~/venv/lib/python3.10/site-packages/trestle/core/markdown/control_markdown_node.py", line 188, in _build_tree
subtree, i = self._build_tree(lines, line, i + 1, level + 1, part_id)
[Previous line repeated 1 more time]
File "~/venv/lib/python3.10/site-packages/trestle/core/markdown/control_markdown_node.py", line 218, in _build_tree
i = self._process_part_line(i, line, lines, content.part, read_parts=read_parts)
File "~/venv/lib/python3.10/site-packages/trestle/core/markdown/control_markdown_node.py", line 427, in _process_part_line
if line.lstrip()[0] != '-' or not read_parts:
IndexError: string index out of range
To Reproduce
Steps to reproduce the behavior:
- Create a profile markdown file with content resembling following or insert the below line in a section of an existing valid profile:
This line is present before the potential tab or spaces in line below:
Following line to the preceding line
- Run
trestle author profile-assemble
after the edit.
Expected behavior
profile.json
assembled from markdown and command exit with code 0
.
Environment
- OS: macos
- Python version:
3.8.13
- Installed packages:
compliance-trestle==2.1.0