Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash on Node2code operation in case of conflicts with non-unique namespaces #9255

Merged
merged 2 commits into from
Nov 21, 2018

Conversation

aparajit-pratap
Copy link
Contributor

@aparajit-pratap aparajit-pratap commented Nov 20, 2018

Purpose

JIRA link: https://jira.autodesk.com/browse/QNTM-5426
GH Issue: #8981

This addresses a crash on performing node to code on class with non-unique namespace with another class: E.g. If there are 2 classes, B.C.List and A.B.C.List, where A, B, and C are namespaces for 2 classes of the same name List, the language cannot distinguish between them even if both classes are pre-qualified with their full namespaces, since in this case B.C.List can be considered a partial namespace for A.B.C.List. In such a case node to code fails to find a (shortest) unique qualified name for example, a List.Count node (as it cannot decide which namespaces to qualify the class List with) and returns a null for the unique name. The code following this step does not account for a null name and thus results in a crash.

The fix is to return the fully qualified name no matter whether it is unique or not so as to prevent the crash and let the code block node throw an error indicating to the user of the namespace conflict as follows:
image

The above graph is a result of a node-to-code command on DSCore.String.ToUpper node in the presence of another class with the same name belonging to namespace X.DSCore.String.

Note: The above error message appears only at compile-time (manual mode). When the graph is executed directly (Auto mode), the runtime error message is not so useful:
image

We can consider displaying the above compilation error (which is more useful to the user) as a future improvement.

Declarations

Check these if you believe they are true

  • The code base 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.

Reviewers

@ColinDayOrg

Colin, this is my take on the issue that you've been investigating. I've added some background describing the current behavior, reasons for the crash, and fix. Please take a look.

FYIs

@mjkkirschner

@ColinDayOrg
Copy link
Contributor

Do we have any test coverage for this? Other than that LGTM.

@ColinDayOrg
Copy link
Contributor

This may possibly address the crash I am looking at, but in the call to CreateNodeFromString from CreateNodeFromShortName there are definitely a couple of places where it is possible to try to dereference a null value. It may still be needed or wanted to add some guard checks. John added some information to the issue that I was going to take a look at today.

@aparajit-pratap
Copy link
Contributor Author

@ColinDayOrg will try adding some tests and will wait for you to finish testing and/or adding further checks if needed. Thanks.

@ColinDayOrg
Copy link
Contributor

This change does appear to address the crash.

@aparajit-pratap
Copy link
Contributor Author

@ColinDayOrg I've added a test. Please let me know if it's good to go.

@ColinDayOrg
Copy link
Contributor

LGTM :shipit:

@aparajit-pratap aparajit-pratap merged commit 896e0b2 into DynamoDS:master Nov 21, 2018
@aparajit-pratap aparajit-pratap deleted the namespaceConflict branch November 21, 2018 02:57
@horatiubota horatiubota added the error/warning/crash Issues mentioning a Dynamo error, warning or crash message label Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error/warning/crash Issues mentioning a Dynamo error, warning or crash message
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants