Skip to content

Prevent self-reference in Node hierarchy with ArgumentException#64

Merged
EbiseLutica merged 5 commits intomasterfrom
copilot/fix-adding-self-as-child
Nov 5, 2025
Merged

Prevent self-reference in Node hierarchy with ArgumentException#64
EbiseLutica merged 5 commits intomasterfrom
copilot/fix-adding-self-as-child

Conversation

Copy link
Contributor

Copilot AI commented Nov 5, 2025

Adding a node to itself as a child currently causes StackOverflowException during UpdateModelMatrix() recursion, making debugging difficult.

Changes

  • Self-reference validation: Added check in ContainableNode.Add() and Insert() to throw ArgumentException with clear message when node == this
  • Bug fix: Corrected Insert() method's parent removal logic from Remove(this) to Remove(node) - was attempting to remove wrong node from parent

Example

var container = new Container();
container.Add(container);  // Now throws: ArgumentException: "ノードの子要素に自分自身を追加することはできません。"
                          // Previously: StackOverflowException (unclear cause)

Tests added to verify exception behavior and correct parent reassignment.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: node /home/REDACTED/work/Promete/Promete/Promete.Docs/node_modules/.bin/astro build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Nodeの子要素として自分自身を追加しようとしたら例外を出すようにする</issue_title>
<issue_description>現時点で、Nodeの子要素に自分を追加するとStackOverFlowExceptionがスローされる

不具合の原因がわかりづらいので、事前にArgumentException例外を出すようにする</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: EbiseLutica <7106976+EbiseLutica@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 5, 2025

Deploying promete with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9de6d53
Status: ✅  Deploy successful!
Preview URL: https://bbb37ddf.promete.pages.dev
Branch Preview URL: https://copilot-fix-adding-self-as-c.promete.pages.dev

View logs

Copilot AI and others added 2 commits November 5, 2025 17:19
Co-authored-by: EbiseLutica <7106976+EbiseLutica@users.noreply.github.com>
Co-authored-by: EbiseLutica <7106976+EbiseLutica@users.noreply.github.com>
Copilot AI changed the title [WIP] Throw ArgumentException when adding self as child node Prevent self-reference in Node hierarchy with ArgumentException Nov 5, 2025
Copilot AI requested a review from EbiseLutica November 5, 2025 17:26
@EbiseLutica EbiseLutica marked this pull request as ready for review November 5, 2025 17:59
@EbiseLutica EbiseLutica merged commit 0fc0630 into master Nov 5, 2025
2 checks passed
@EbiseLutica EbiseLutica deleted the copilot/fix-adding-self-as-child branch November 5, 2025 18:00
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.

Nodeの子要素として自分自身を追加しようとしたら例外を出すようにする

2 participants