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

the-graph-clipboard:makeNewId() makes bad Ids #224

Open
davidmaxwaterman opened this issue Aug 10, 2015 · 2 comments
Open

the-graph-clipboard:makeNewId() makes bad Ids #224

davidmaxwaterman opened this issue Aug 10, 2015 · 2 comments
Labels

Comments

@davidmaxwaterman
Copy link

Perhaps this is a problem with the toJSON() function, but this is the origin of the problem. It creates node ids using the component, but the range of valid characters for component and process name are not the same - specifically, a component can contain the slash character '/', but processes cannot.

  var makeNewId = function (label) {
    var num = 60466176; // 36^5
    num = Math.floor(Math.random() * num);
    var id = label + '_' + num.toString(36);
    return id;
  };
...
     newNode.id = makeNewId(node.component);

This results in us having to post-process the process names to make them valid (but also introduces a source of potential bugs since we should really ensure the process names are still unique).

Any thoughts on this?

@davidmaxwaterman
Copy link
Author

there doesn't seem to be any check to see if the new id is actually already used...did I miss something, or are we assuming duplicate random numbers are so unlikely that it won't ever happen?

@forresto
Copy link
Collaborator

Looks like we're not checking. I don't like that assumption!

@jonnor jonnor added the bug label Jul 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants