Skip to content

DYN-9707: Refactor ForceBlockRun to instance #17153

Open
ivaylo-matov wants to merge 5 commits into
DynamoDS:masterfrom
ivaylo-matov:DYN-9707-Refactor-ForceBlockRun-to-instance_
Open

DYN-9707: Refactor ForceBlockRun to instance #17153
ivaylo-matov wants to merge 5 commits into
DynamoDS:masterfrom
ivaylo-matov:DYN-9707-Refactor-ForceBlockRun-to-instance_

Conversation

@ivaylo-matov

Copy link
Copy Markdown
Contributor

Purpose

This PR is related to DYN-9707 and is a follow-up to this comment.

Changes:

  • converted RunSettings.ForceBlockRun from static to instance to prevent potential race conditions caused by opening two consecutive .dyn files from untrusted locations.
  • moved the logic for deciding if the trust warning should be displayed to an internal helper in DynamoModel.
  • added a new private helper in DynamoViewModel to ensure the file trust warning is dismissed properly. Previously, the warning closed only when the user clicks the Yes/No buttons or closes the untrusted graph. If a user opened a new graph from a trusted location without closing the prior untrusted graph or dismissing its file trust warning, the warning would remain stale and visible, even though the new trusted graph was permitted to execute.
  • added a new regression test to verify this updated behavior.

Before:


DYN-9707-Part2-Before

After:


DYN-9707-Part2-After

Declarations

Check these if you believe they are true

Release Notes

This PR refactors RunSettings.ForceBlockRun to instance and ensures file trust warning does not ream stale in some edge cases.

Reviewers

@DynamoDS/eidos
@jasonstratton

FYIs

@dnenov
@johnpierson

@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-9707

@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

@jasonstratton

Copy link
Copy Markdown
Contributor

Hi @ivaylo-matov , I did see this PR and then saw your message on the previous PR. Since you posted the message advertising this PR, I was wondering if it is ready for review then? Thanks.

@ivaylo-matov

Copy link
Copy Markdown
Contributor Author

Hi @jasonstratton , the PR is ready for review. Thanks

@ivaylo-matov

Copy link
Copy Markdown
Contributor Author

I see SelfServe has failed, but I can't see the details.
Not Found This page may not exist, or you may not have permission to see it.

@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.

A couple of code changes needed and to test the CLI, but it looks good.

Assert.IsFalse(string.IsNullOrEmpty(ViewModel.FileTrustViewModel.DynFileDirectoryName));

// Arrange - place file B in a dedicated trusted subcategory
var trustedDir = Path.Combine(TempFolder, trustedDirName);

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.

Local var here. I think you should use the instance var

[TestFixture]
public class FileTrustWarirngTests : DynamoTestUIBase
{
private string trustedDir;

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.

Instance var here

[TearDown]
public void Cleanup()
{
if (trustedDir != null)

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.

Because the test is using a local var, the instance var is always null and the cleanup does not happen

/// <summary>
/// Returns true when grahp execution shoudl be blocked pending file trust aknowledgement
/// </summary>
/// <param name="filePath"></param>

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.

Nitpick: Typos in the

and is empty

namespace DynamoCoreWpfTests
{
[TestFixture]
public class FileTrustWarirngTests : DynamoTestUIBase

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.

Class name and file name typo

/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
internal bool ShouldForceBlockRun(string filePath)

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.

Please test in headless mode.

ShouldForceBlockRun() is called from OpenJsonFile(), which is called in both Dynamo UI and Dynamo headless ... but there is no UI to trust and set homeWorkspace.RunSettings.ForceBlockRun back to false.

Only places to clear homeWorkspace.RunSettings.ForceBlockRun are in the view layer. OpenJsonFile() here is in the DynamoModel.

I think what will end up happening is that if this method returns true in headless mode, it will silently fail to run the graphs.

The precondition for this is: DynamoCLI opens a .dyn where IsTestMode = false and the file's directory is not in the trusted locations list and DisableTrustWarnings = false. ... Is this a realistic scenario? I'm not 100% sure. If so, this needs to be fixed and maybe add some tests.

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.

2 participants