Skip to content

DYN-6409: Disable PM requests with no-network mode#16191

Closed
aparajit-pratap wants to merge 12 commits intoDynamoDS:masterfrom
aparajit-pratap:dyn-6409
Closed

DYN-6409: Disable PM requests with no-network mode#16191
aparajit-pratap wants to merge 12 commits intoDynamoDS:masterfrom
aparajit-pratap:dyn-6409

Conversation

@aparajit-pratap
Copy link
Contributor

@aparajit-pratap aparajit-pratap commented May 7, 2025

Purpose

Disable PM requests with no-network mode
Disable web request node with no-network mode

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB

Release Notes

Disable PM request and web request node with no-network mode.

Reviewers

(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)

(FILL ME IN, optional) Any additional notes to reviewers or testers.

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

@github-actions github-actions bot changed the title Dyn 6409: Disable PM requests with no-network mode DYN-: Dyn 6409: Disable PM requests with no-network mode May 7, 2025
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

@aparajit-pratap aparajit-pratap changed the title DYN-: Dyn 6409: Disable PM requests with no-network mode DYN-6409: Disable PM requests with no-network mode May 7, 2025
@aparajit-pratap aparajit-pratap requested a review from a team May 7, 2025 14:42
@aparajit-pratap aparajit-pratap requested a review from Copilot May 20, 2025 17:06
Copy link
Contributor

Copilot AI left a comment

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 disables Package Manager requests and disables the web request node when no-network mode is enabled. Key changes include:

  • Updating test mocks to include a new parameter ("false") for noNetworkMode in various PackageManagerClient constructors.
  • Adding a new parameter key (NoNetworkMode) and integrating it into the execution session and preferences.
  • Inserting runtime checks across core libraries and view models to short-circuit PM and web functionalities when no-network mode is active.

Reviewed Changes

Copilot reviewed 13 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/DynamoCoreWpf2Tests/PackageManager/PackageManagerUITests.cs Updated PackageManagerClient instantiation with noNetworkMode flag.
test/DynamoCoreWpf2Tests/PackageManager/PackageManagerSearchElementViewModelTests.cs Updated PackageManagerClient mock constructions to include noNetworkMode parameter.
test/DynamoCoreWpf2Tests/PackageManager/PackageManagerControlTests.cs Propagated noNetworkMode parameter in client creation.
src/NodeServices/ExecutionSession.cs Added ParameterKeys.NoNetworkMode with an empty XML comment.
src/Libraries/CoreNodes/Web.cs Inserted a check to prevent web requests when in no-network mode.
src/DynamoPackages/PackageManagerExtension.cs Injected noNetworkMode value into PackageManagerClient construction.
src/DynamoPackages/PackageManagerClient.cs Integrated noNetworkMode checks across multiple methods to disable functionality appropriately.
src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerClientViewModel.cs Updated publish and permission checks to honor noNetworkMode.
src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs Added NoNetworkMode property and initialized it from DynamoViewModel.
src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs Altered Package Manager display conditions to account for noNetworkMode.
src/DynamoCore/Configuration/ExecutionSession.cs Ensured that NoNetworkMode is passed into the execution session parameters.
Files not reviewed (8)
  • doc/distrib/xml/en-US/DSCoreNodes.xml: Language not supported
  • src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml: Language not supported
  • src/DynamoPackages/Properties/Resources.Designer.cs: Language not supported
  • src/DynamoPackages/Properties/Resources.en-US.resx: Language not supported
  • src/DynamoPackages/Properties/Resources.resx: Language not supported
  • src/Libraries/CoreNodes/Properties/Resources.Designer.cs: Language not supported
  • src/Libraries/CoreNodes/Properties/Resources.en-US.resx: Language not supported
  • src/Libraries/CoreNodes/Properties/Resources.resx: Language not supported

@zeusongit
Copy link
Contributor

Do we also use this property to block fetching feature flags?

@aparajit-pratap
Copy link
Contributor Author

Do we also use this property to block fetching feature flags?

Yes, it's already blocked here.

Copy link
Contributor

@zeusongit zeusongit left a comment

Choose a reason for hiding this comment

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

LGTM, missing public API failing the build though

Copy link
Contributor

Copilot AI left a comment

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 adds support for a “no-network” (offline) mode by introducing a NoNetworkMode parameter across the execution session, preventing network calls in core nodes, package manager logic, and UI commands when offline.

  • Introduced NoNetworkMode in ExecutionSession and a helper to block executions
  • Added guards in Web nodes and PackageManagerClient methods to disable calls when offline
  • Updated view models to disable related UI actions under no-network mode

Reviewed Changes

Copilot reviewed 16 out of 26 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/NodeServices/ExecutionSession.cs Added NoNetworkMode parameter key and ThrowIfNoNetworkMode helper
src/Libraries/CoreNodes/Web.cs Invoked offline-mode guard in WebRequestByUrl
src/Libraries/CoreNodeModels/WebRequest.cs Updated NodeDescription resource reference
src/DynamoPackages/PackageManagerClient.cs Added NoNetworkMode flag and conditional returns/throws
src/DynamoPackages/PackageManagerExtension.cs Passed noNetworkMode into PackageManagerClient constructor
src/DynamoCoreWpf/ViewModels/PackageManagerClientViewModel.cs Disabled publish commands when offline
src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs Exposed NoNetworkMode in preferences
src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs Disabled package manager menu when offline
src/DynamoCore/Models/DynamoModel.cs Clarified NoNetworkMode docstring
src/DynamoCore/Configuration/ExecutionSession.cs Propagated NoNetworkMode into execution parameters
Files not reviewed (10)
  • doc/distrib/xml/en-US/DSCoreNodes.xml: Language not supported
  • src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml: Language not supported
  • src/DynamoPackages/Properties/Resources.Designer.cs: Language not supported
  • src/DynamoPackages/Properties/Resources.en-US.resx: Language not supported
  • src/DynamoPackages/Properties/Resources.resx: Language not supported
  • src/Libraries/CoreNodes/Properties/Resources.Designer.cs: Language not supported
  • src/Libraries/CoreNodes/Properties/Resources.en-US.resx: Language not supported
  • src/Libraries/CoreNodes/Properties/Resources.resx: Language not supported
  • src/NodeServices/DynamoServices.csproj: Language not supported
  • src/NodeServices/Properties/Resources.Designer.cs: Language not supported
Comments suppressed due to low confidence (1)

src/DynamoPackages/PackageManagerClient.cs:426

  • If CompatibilityMap() returns null in offline mode, this loop will throw a NullReferenceException. Add a null check before iterating.
foreach (var host in compatibilityMapList)

{
if ((bool)session.GetParameterValue(ParameterKeys.NoNetworkMode))
{
throw new Exception(DynamoServices.Properties.Resources.WebRequestOfflineWarning);
Copy link

Copilot AI May 22, 2025

Choose a reason for hiding this comment

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

Throwing a general Exception can obscure intent; consider using InvalidOperationException or a custom exception to indicate offline mode.

Suggested change
throw new Exception(DynamoServices.Properties.Resources.WebRequestOfflineWarning);
throw new InvalidOperationException(DynamoServices.Properties.Resources.WebRequestOfflineWarning);

Copilot uses AI. Check for mistakes.

internal List<string> UserVotes()
{
if (NoNetworkMode) return null;
Copy link

Copilot AI May 22, 2025

Choose a reason for hiding this comment

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

Returning null for a list can lead to NullReferenceExceptions. Prefer returning an empty list (new List<string>()) to maintain API consistency.

Suggested change
if (NoNetworkMode) return null;
if (NoNetworkMode) return new List<string>();

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This?

{
try
{
if (NoNetworkMode) throw new Exception(DynamoPackages.Properties.Resources.DownloadPackageDisabled);
Copy link

Copilot AI May 22, 2025

Choose a reason for hiding this comment

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

[nitpick] This method throws an exception on offline mode, but other methods return null or defaults. Consider unifying the error-handling strategy across package manager methods.

Suggested change
if (NoNetworkMode) throw new Exception(DynamoPackages.Properties.Resources.DownloadPackageDisabled);
if (NoNetworkMode)
{
pathToPackage = null;
return PackageManagerResult.Failed(DynamoPackages.Properties.Resources.DownloadPackageDisabled);
}

Copilot uses AI. Check for mistakes.
</data>
<data name="CurveMapperEqualMinMaxWarning" xml:space="preserve">
<value>• Min and Max values must not be the same.</value>
<value>• Min and Max values must be different.</value>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change looks like it is already in master, wonder why it is showing as change here.

@aparajit-pratap
Copy link
Contributor Author

@reddyashish PTAL #16238
I'm most probably going to close this one.

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.

5 participants