There seems to be a bug with linting a docx report. When Creating a report template, and submitting, we see the expected warning:
Template is missing a recommended style (see documentation): CodeInline
As well as an error below:
Template rendering failed unexpectedly
Looking at the logs, we see the following:
INFO 2024-07-23 23:21:43,756 signals 18 137756409506616 Deleted old template file /app/ghostwriter/media/templates/v5.1-ghostwriter-executive-document_OTcPzou.docx
INFO 2024-07-23 23:21:43,756 signals 18 137756409506616 Template file change detected, so starting linter
INFO 2024-07-23 23:21:43,757 signals 18 137756409506616 Linting newly uploaded template: /app/ghostwriter/media/templates/v5.1-ghostwriter-executive-document_QUbTZfD.docx
INFO 2024-07-23 23:21:43,757 docx 18 137756409506616 Linting docx file '/app/ghostwriter/media/templates/v5.1-ghostwriter-executive-document_QUbTZfD.docx'
INFO 2024-07-23 23:21:43,807 docx 18 137756409506616 Template loaded for linting
ERROR 2024-07-23 23:21:44,136 docx 18 137756409506616 Template failed linting
Traceback (most recent call last):
File "/app/ghostwriter/modules/reportwriter/base/docx.py", line 282, in lint
if document_styles[style].type != WD_STYLE_TYPE.CHARACTER:
File "/usr/local/lib/python3.10/site-packages/docx/styles/styles.py", line 53, in __getitem__
raise KeyError("no style with name '%s'" % key)
KeyError: "no style with name 'CodeInline'"
INFO 2024-07-23 23:21:44,137 docx 18 137756409506616 Linting finished: 1 warnings, 1 errors
INFO: 172.24.0.4:59414 - "POST /reporting/templates/update/16 HTTP/1.0" 302 Found
INFO: 172.24.0.4:59424 - "GET /reporting/templates/16 HTTP/1.0" 200 OK
I was able to track down the code within file ./ghostwriter/modules/reportwriter/base/docx.py.
Running a git reset before the commit, rebuilding images, and spinning up the containers, the report is able to be created.
Docker [e.g., output of docker --version and docker-compose -v]
Docker version 24.0.6, build ed223bc
docker-compose version 1.29.2, build 5becea4c
Ghostwriter
Latest as of today July 23rd, 2024 in main github branch
Additional context
Looks like template style is throwing a traceback rather than handling the error as a warning. I assume the correct path forward is to catch this error and report a warning, allowing the linting to continue.
Thanks for letting me know. It's a simple fix that will go out in the next release. For now, you will be able to use the template if the style is defined in the template.
Describe the bug
There seems to be a bug with linting a docx report. When Creating a report template, and submitting, we see the expected warning: Template is missing a recommended style (see documentation): CodeInline As well as an error below: Template rendering failed unexpectedly
Looking at the logs, we see the following:
I was able to track down the code within file ./ghostwriter/modules/reportwriter/base/docx.py.
Running a git reset before the commit, rebuilding images, and spinning up the containers, the report is able to be created.
To Reproduce Steps to reproduce the behavior:
Expected Behavior
Screenshots Bah, didn't get this since I have already rolled back. If unable to reproduce issue, let me know and I'll update and grab this for you.
Server Specs:
docker --version
anddocker-compose -v
]Additional context Looks like template style is throwing a traceback rather than handling the error as a warning. I assume the correct path forward is to catch this error and report a warning, allowing the linting to continue.