DYN-: Dyn 10540 template folder tree read only in dynamo#17190
Conversation
There was a problem hiding this comment.
See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-10540
Updated template save validation to block saves anywhere under the templates root, not only the active localized folder like templates\en-US. Added path normalization so unrelated folders like templates-other are not blocked accidentally. Preserved custom template folder behaviour by treating the custom configured folder as its own root. Added unit tests for template root, localized/sibling folders, outside paths, and custom template paths.
aa0b079 to
d1fe2e4
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates Dynamo’s “template workspace” save validation to prevent users from saving graphs anywhere inside the shipped Templates folder tree (the root templates folder and all localized subfolders), addressing DYN-10540.
Changes:
- Replaced the prior substring-based check (
path.Contains(...)) with a normalized “is under templates root” path check. - Added
DynamoViewModel.IsPathInTemplateDirectoryTree(...)(and helper root-resolution logic) to reliably detect saves under the shipped Templates tree. - Added unit tests covering blocked vs allowed save paths, including sibling locale folders and custom template roots.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs |
Updates save validation and adds a normalized path-in-template-tree helper. |
test/DynamoCoreWpf3Tests/WorkspaceSaving.cs |
Adds unit tests verifying the new template save path blocking behavior. |
Restrict the parent-climb to the templates root to only trigger when the leaf directory looks like a locale folder (e.g. en-US). Previously, a custom templates path whose parent happened to be named "templates" (e.g. D:\MyWork\templates\CustomTemplates) would incorrectly climb up and block saves across the whole parent tree. Added a test assertion covering this edge case. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Added one commit on top to address Copilot's inline comment about The issue: The parent-name check ( The fix: Added a locale-directory guard ( All 3 template path tests pass locally. |
jasonstratton
left a comment
There was a problem hiding this comment.
There was one Copilot comment that needed to be addressed. It was a one liner and updated test. So I just did it.
Approved and will merge. Thank you.
|



Purpose
This PR addresses DYN-10540.
The changes in the code aim to to prevent users from saving Dynamo graphs anywhere inside the shipped Templates folder tree.
Previously, Dynamo only blocked saves inside the currently resolved localized template folder, for example templates\en-US. This meant users could still save files directly into the parent templates folder or into another localized subfolder such as templates\en-GB.
The update changes the save validation so Dynamo checks against the full template root instead of only the active localized folder. It also normalizes paths before comparing them, so unrelated folders with similar names are not blocked by accident. Custom template locations are still handled as their own template root.
Changes :
-Updated the save validation so Dynamo blocks saves anywhere inside the full templates folder tree, not only the active localized folder such as templates\en-US.
-Added path normalization before comparing save paths, so similarly named folders outside the template tree are not blocked accidentally.
-Preserved custom template location behavior by treating the configured custom template folder as its own root.
-Added unit tests covering saves into the template root, active localized folder, sibling localized folders, unrelated folders, and custom template paths.
Note :
One related behaviour came up during testing: Dynamo remembers the last save location and uses it as the initial folder the next time a template workspace is saved. In ShowSaveDialogAndSaveResult, template workspaces use LastSavedLocation for the Save As dialog. After the user selects a path, LastSavedLocation is updated from _fileDialog.FileName immediately after calling SaveAs(...).
This means that if a user tries to save a template into the blocked templates folder tree, the save is prevented, but that selected folder can still become the last saved location. The next time the user presses Ctrl+S, Dynamo may open Save As in the same blocked folder again, causing the warning to appear repeatedly unless the user manually chooses another location.
This is separate from the current PR’s scope and may need follow-up work so LastSavedLocation and IsTemplate are only updated after a save actually succeeds.
Declarations
Check these if you believe they are true
Release Notes
Improved template save validation so Dynamo no longer allows saving graphs inside the shipped Templates folder tree.
Reviewers
@zeusongit
@DynamoDS/eidos
FYIs
@dnenov
@johnpierson
@jnealb
@jasonstratton