fix: reject self-parenting in PanObject child operations - #628
Open
Shubham-Padkonde wants to merge 1 commit into
Open
Shubham-Padkonde wants to merge 1 commit into
Shubham-Padkonde wants to merge 1 commit into
Conversation
Signed-off-by: Shubham Padkonde <shubhampadkonde12@gmail.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.
Description
Fixes #512.
Adding a
PanObjectas its own child makes its parent point back to itself, so later operations such asvsys,delete()anddelete_similar()can recurse indefinitely. Reject that operation withValueErrorbefore modifying the tree.Apply the same validation to
insert()andextend(), which can create the same invalid relationship.extend()validates the complete batch before changing any child's parent, so rejection leaves existing parent links intact. The methods document the new error, and three regression tests verify rejection and unchanged state. This prevents direct self-parenting; it does not introduce broader ancestor-cycle or reparenting policy changes.Validation
Ubuntu 22.04/WSL, Poetry 1.7.1, dependencies from the existing lockfile:
develop(92ed648d) and pass with the fix.make check-formatpasses (Black and isort).make lintstill fails on existing repository findings: 4,146 after this patch versus 4,149 on unchanged source. Comparison ignoring shifted line numbers finds no added diagnostics.make banditstill reports the same eight findings as unchanged source; no new findings.git diff --checkpasses. No dependency files changed.The legacy
make test-alltarget uses a Python 2.7 tox configuration and callssetup.py, which is absent from the current checkout; that target was not used as evidence. The actual CI Python versions were tested directly. Live-device tests and macOS were not exercised. The pinned pytest also fails during startup on Python 3.10, so validation uses the supported CI versions above.Investigation, implementation and testing were assisted by Codex/GPT-6.