fix: file handle leak, viewBox null check, and stale op_id bug#81
Merged
deacon-mp merged 1 commit intomitre:masterfrom Mar 16, 2026
Merged
fix: file handle leak, viewBox null check, and stale op_id bug#81deacon-mp merged 1 commit intomitre:masterfrom
deacon-mp merged 1 commit intomitre:masterfrom
Conversation
…eps_d3 - c_story.py: use context manager for svg.write() to prevent file handle leak - c_story.py: add null check for missing viewBox attribute in adjust_icon_svgs - debrief_svc.py: use operation.id instead of stale op_id loop variable in build_steps_d3 second loop (was referencing last value from first loop)
601a0c8 to
fdb698d
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes three bugs: a file handle leak when writing SVGs, a null-pointer crash when SVG elements lack a viewBox attribute, and a stale loop variable (op_id) causing incorrect graph data when debriefing multiple operations.
Changes:
- Added a null check for the
viewBoxattribute and replaced the leakingopen()call with a context manager inadjust_icon_svgs(). - Replaced stale
op_idreferences withoperation.idin the second loop ofbuild_steps_d3(), ensuring each operation's nodes and links use the correct operation identifier.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
app/objects/c_story.py |
Fixes file handle leak via context manager and adds null check for missing viewBox attribute |
app/debrief_svc.py |
Replaces stale op_id variable with operation.id in the graph-building loop |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
c_story.py:adjust_icon_svgs()—svg.write(open(path, 'wb'))never closes the file handle. Fixed with context manager.c_story.py:adjust_icon_svgs()— crashes if an SVG element lacks aviewBoxattribute. Added null check withcontinue.op_idvariable indebrief_svc.py:build_steps_d3()— the secondfor operation in operationsloop referencedop_idfrom the first loop, causing all operation nodes/links to use the lastop_idvalue when multiple operations are debriefed. Fixed to useoperation.id.Test plan
🤖 Generated with Claude Code