Skip to content

fix: Robust path resolution for choices in leaf nodes#7

Merged
samdammers merged 1 commit intomainfrom
fix-path-traversal
Feb 15, 2026
Merged

fix: Robust path resolution for choices in leaf nodes#7
samdammers merged 1 commit intomainfrom
fix-path-traversal

Conversation

@samdammers
Copy link
Owner

@samdammers samdammers commented Feb 15, 2026

Fixes critical regressions where choices residing in nested containers or leaf nodes were resolving their target paths incorrectly.

The root cause was twofold:

  1. BaseRuntimeObject.GetPath() was losing type identity when called on a Container via struct embedding. This caused parent containers to fail INamedContent checks, leading to index-based paths instead of named paths.
  2. Relative path calculation for choices was brittle when traversing up from leaf nodes.

Changes:

  • Override GetPath() on *Container to pass the correct *Container instance to parents, ensuring named content is resolved by name.
  • Improve robustness of path resolution logic for choice points in leaf nodes.
  • Add regression test TestNestedChoicePathResolution to verify behavior with nested story structures.
  • Add architecture decision 0004-container-getpath-override.md documenting the Go-specific embedding pitfall.
  • Update 03-java-vs-go.md with notes on method promotion vs virtual dispatch differences.

Fixes critical regressions where choices residing in nested containers or leaf nodes were resolving their target paths incorrectly.

The root cause was twofold:
1. `BaseRuntimeObject.GetPath()` was losing type identity when called on a `Container` via struct embedding. This caused parent containers to fail `INamedContent` checks, leading to index-based paths instead of named paths.
2. Relative path calculation for choices was brittle when traversing up from leaf nodes.

Changes:
- Override `GetPath()` on `*Container` to pass the correct `*Container` instance to parents, ensuring named content is resolved by name.
- Improve robustness of path resolution logic for choice points in leaf nodes.
- Add regression test `TestNestedChoicePathResolution` to verify behavior with nested story structures.
- Add architecture decision `0004-container-getpath-override.md` documenting the Go-specific embedding pitfall.
- Update `03-java-vs-go.md` with notes on method promotion vs virtual dispatch differences.
@samdammers samdammers merged commit 1437d9d into main Feb 15, 2026
4 checks passed
@samdammers samdammers deleted the fix-path-traversal branch February 15, 2026 05:02
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.

1 participant