speckleworks / SpeckleCore

Check a brand new Speckle at: https://github.com/specklesystems
https://speckle.systems
MIT License
38 stars 17 forks source link

Risks of API calls within deserialisation constructor of SpeckleApiClient #131

Open nic-burgers-arup opened 4 years ago

nic-burgers-arup commented 4 years ago

Step 0:

Actual Behaviour

What's actually going on! Deserialising SpeckleApiClients causes an API call to StreamGetAsync.

Affected Projects

Does this issue propagate to other dependencies or dependants? If so, list them here! SpeckleGrasshopper deserialises SpeckleApiClients and in so doing triggers an API call to the Speckle server. If any exceptions are thrown, then the object returned is null, and therefore the context (e.g. stream ID) is lost, which means it can't be preserved when the GH file is subsequently saved.

Reproduction Steps & System Config (win, osx, web, etc.)

  1. Save GH file with Speckle receiver or sender
  2. Open the pre-saved file

Proposed Solution (if any)

This might be superseded by a wider conversation about whether such a call is even necessary, but assuming it is then I propose moving that API call outside of the constructor into another method, and altering the connectors (like SpeckleGrasshopper) to make a separate new call after the SpeckleApiClient is deserialised.