Skip to content

fix: harden report template for missing fields#58

Open
AlwinXue wants to merge 1 commit intoOSIPI:mainfrom
AlwinXue:alwin/fix-issue-38
Open

fix: harden report template for missing fields#58
AlwinXue wants to merge 1 commit intoOSIPI:mainfrom
AlwinXue:alwin/fix-issue-38

Conversation

@AlwinXue
Copy link
Copy Markdown

@AlwinXue AlwinXue commented Mar 31, 2026

Hi mentors! 👋

This PR addresses the PDF generation crash reported in Issue #38.

The Problem:
The render_report_html function used strict dictionary lookups and assumed a single data shape for asl_parameters. If the processor output omitted keys like basic_report or extended_report, or if asl_parameters arrived as a dictionary instead of a list of tuples, the PDF endpoint crashed before it could render a response.

The Solution:
Safe Lookups: Replaced strict indexing with .get() calls and added sensible fallback strings for missing report sections.
Format Flexibility: Added support for asl_parameters as either a dictionary or an iterable of (key, value) pairs.
Key Fallbacks: The template now checks missing_required_parameters first and falls back to missing_parameters for older payloads.
Regression Coverage: Added a targeted backend test to verify the PDF endpoint still works when missing_required_parameters is provided and report text fields are absent.

Validation:
Ran python -m pytest tests/test_report.py -q -k "test_report_pdf_endpoint or test_report_pdf_endpoint_uses_missing_required_parameters" (with DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib) and both targeted PDF tests passed.

Fixes #38

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

render_report_html crashes with KeyError when processor output is missing expected keys

1 participant