fix: prevent absolute image paths from being written to save files#99
Open
beneaze wants to merge 1 commit into
Open
fix: prevent absolute image paths from being written to save files#99beneaze wants to merge 1 commit into
beneaze wants to merge 1 commit into
Conversation
When a component image lives outside both the package and all configured libraries, to_relative_path() returned the absolute path unchanged, which was then blindly written to image_path in the save file. Absolute paths break portability — the file stops working on any other machine or after a home-directory move. The fix checks whether to_relative_path()'s result is still absolute and, if so, leaves image_path_serialized as "" rather than writing the absolute path. Priority is unchanged: @library/... > package-relative > "". The old inner `if rec.image_path / else: ""` branch was dead code (the outer guard already ensures rec.image_path is truthy) and is removed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
serialize_componentwas writing raw absolute paths toimage_pathin save files whenever a component's image lived outside both the built-in package and all configured librariesto_relative_path()explicitly falls back to returning the absolute path for such images, and the old code used its return value unconditionallyPath(rel_path).is_absolute()after the call and leaveimage_path_serializedas""if still absolute — no absolute paths ever reach the save fileAlso removes a dead-code inner
if rec.image_path / else: ""branch (unreachable since the outer guard already ensuresrec.image_pathis truthy).Serialization priority (unchanged except last step)
@library/{lib}/{component}/...""(was: absolute path)Test plan
pytest tests/core/test_component_record.py— all 14 tests pass@library/...pathimage_pathis""in the JSON rather than an absolute path🤖 Generated with Claude Code