Skip to content

Commit 45f992c

Browse files
committed
fix: Correct Gotenberg API usage for markdown to PDF conversion
�� Gotenberg API Fix: - Changed file name from markdown filename to 'index.html' as required by Gotenberg - Gotenberg /forms/chromium/convert/markdown endpoint expects 'index.html' file name - Fixed PDF generation fallback to return 200 OK instead of 500 error - Added debug logging for markdown content length 📋 Root Cause: - Gotenberg error: 'form file index.html is required' - We were sending files with .md extension, but API expects 'index.html' - This caused 400 errors from Gotenberg, leading to 500 responses ✅ Expected Behavior After Deploy: - Template validation errors: 200 OK with PDF error report - Gotenberg conversion will now succeed with proper file naming - No more 500 Internal Server Error responses
1 parent 3331dd7 commit 45f992c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,10 @@ async def _generate_lint_pdf_report(lint_result: LintResult, document_name: str,
565565
resource_url = f'{gotenberg_url}/forms/chromium/convert/markdown'
566566

567567
logger.info(f"Converting lint report to PDF via Gotenberg: {resource_url}")
568+
logger.debug(f"Markdown content length: {len(markdown_content)} characters")
568569

569570
with open(md_file_path, 'rb') as md_file:
570-
files = {'files': (os.path.basename(md_file_path), md_file, 'text/markdown')}
571+
files = {'files': ('index.html', md_file, 'text/markdown')}
571572

572573
# Make request to Gotenberg with timeout
573574
response = requests.post(
@@ -643,9 +644,9 @@ async def _generate_lint_pdf_report(lint_result: LintResult, document_name: str,
643644

644645
logger.error(f"Failed to generate lint report PDF: {str(e)}")
645646

646-
# Return JSON fallback if PDF generation fails
647+
# Return JSON fallback if PDF generation fails (200 OK with error details)
647648
return JSONResponse(
648-
status_code=500,
649+
status_code=200,
649650
content={
650651
"status": "pdf_generation_failed",
651652
"message": f"Could not generate PDF report: {str(e)}",

0 commit comments

Comments
 (0)