fix: harden report template for missing fields#58
Open
AlwinXue wants to merge 1 commit intoOSIPI:mainfrom
Open
fix: harden report template for missing fields#58AlwinXue wants to merge 1 commit intoOSIPI:mainfrom
AlwinXue wants to merge 1 commit intoOSIPI:mainfrom
Conversation
Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi mentors! 👋
This PR addresses the PDF generation crash reported in Issue #38.
The Problem:
The
render_report_htmlfunction used strict dictionary lookups and assumed a single data shape forasl_parameters. If the processor output omitted keys likebasic_reportorextended_report, or ifasl_parametersarrived 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_parametersas either a dictionary or an iterable of(key, value)pairs.Key Fallbacks: The template now checks
missing_required_parametersfirst and falls back tomissing_parametersfor older payloads.Regression Coverage: Added a targeted backend test to verify the PDF endpoint still works when
missing_required_parametersis 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"(withDYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib) and both targeted PDF tests passed.Fixes #38