Skip to content

DYN-: Dyn 10540 template folder tree read only in dynamo#17190

Merged
jasonstratton merged 3 commits into
DynamoDS:masterfrom
Chloepeg:DYN-10540-Template-folder-tree-read-only-in-Dynamo
Jun 23, 2026
Merged

DYN-: Dyn 10540 template folder tree read only in dynamo#17190
jasonstratton merged 3 commits into
DynamoDS:masterfrom
Chloepeg:DYN-10540-Template-folder-tree-read-only-in-Dynamo

Conversation

@Chloepeg

Copy link
Copy Markdown
Contributor

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.

DYN-10540 gif

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

@github-actions github-actions Bot changed the title Dyn 10540 template folder tree read only in dynamo DYN-: Dyn 10540 template folder tree read only in dynamo Jun 23, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@johnpierson johnpierson force-pushed the DYN-10540-Template-folder-tree-read-only-in-Dynamo branch from aa0b079 to d1fe2e4 Compare June 23, 2026 21:08
@johnpierson johnpierson requested a review from Copilot June 23, 2026 21:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
johnpierson and others added 2 commits June 23, 2026 15:19
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>
@jasonstratton

Copy link
Copy Markdown
Contributor

Added one commit on top to address Copilot's inline comment about GetTemplateRootDirectory.

The issue: The parent-name check (parent.Name == "templates") was too broad — a custom templates path like D:\MyWork\templates\CustomTemplates would incorrectly climb up to D:\MyWork\templates and block saves across that whole parent tree instead of just CustomTemplates.

The fix: Added a locale-directory guard (name.Length == 5 && name[2] == '-') so the climb only triggers when the leaf actually looks like a shipped locale folder (e.g. en-US, fr-FR). The custom-path test in TemplateSavePathCheckUsesCustomTemplateFolderAsRoot was extended with an assertion covering this edge case.

All 3 template path tests pass locally.

@jasonstratton jasonstratton left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jasonstratton jasonstratton merged commit 04173ec into DynamoDS:master Jun 23, 2026
24 checks passed
@sonarqubecloud

Copy link
Copy Markdown

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.

4 participants