Failed to extract (pre-serialize) properties from the

Hi,

I am not sure if this is specifically a Speckle Automate bug or not but I have only ever noticed this within Speckle Automate.

I am trying to send a custom object defined in the Automate function and receiving the following exception:

Summary
[bbb455b6e9-dd3d265ce4-0] Speckle.Core.Logging.SpeckleException: Failed to extract (pre-serialize) properties from the SpeckleAutomate.Federation.FederationModel
[bbb455b6e9-dd3d265ce4-0]    at Speckle.Core.Serialisation.BaseObjectSerializerV2.Serialize(Base baseObj)
[bbb455b6e9-dd3d265ce4-0]    at Speckle.Core.Api.Operations.SerializerSend(Base value, BaseObjectSerializerV2 serializer, CancellationToken cancellationToken)
[bbb455b6e9-dd3d265ce4-0]    at Speckle.Core.Api.Operations.Send(Base value, IReadOnlyCollection`1 transports, Action`1 onProgressAction, CancellationToken cancellationToken)
[bbb455b6e9-dd3d265ce4-0] Speckle.Core.Logging.SpeckleException: Failed to extract (pre-serialize) properties from the SpeckleAutomate.Federation.FederationModel
[bbb455b6e9-dd3d265ce4-0]    at Speckle.Core.Serialisation.BaseObjectSerializerV2.Serialize(Base baseObj)
[bbb455b6e9-dd3d265ce4-0]    at Speckle.Core.Api.Operations.SerializerSend(Base value, BaseObjectSerializerV2 serializer, CancellationToken cancellationToken)
[bbb455b6e9-dd3d265ce4-0]    at Speckle.Core.Api.Operations.Send(Base value, IReadOnlyCollection`1 transports, Action`1 onProgressAction, CancellationToken cancellationToken)
[bbb455b6e9-dd3d265ce4-0]    at Speckle.Automate.Sdk.AutomationContext.CreateNewVersionInProject(Base rootObject, String branchName, String versionMessage)
[bbb455b6e9-dd3d265ce4-0]    at AutomateFunction.Run(AutomationContext automationContext, FunctionInputs functionInputs) in /src/AutomateFunction.cs:line 73
[bbb455b6e9-dd3d265ce4-0]    at Speckle.Automate.Sdk.AutomationRunner.RunFunction[TInput](Func`3 automateFunction, AutomationRunData automationRunData, String speckleToken, TInput inputs)

Any tips/ideas/suggestions to resolve the exception or what could be causing it?

Thanks,
Daniel

Link to the Automation: https://automate.speckle.dev/automations/81e5fd797f
Link to the Function: https://automate.speckle.dev/functions/bbb455b6e9
Link to the GitHub: GitHub - sanchez/SA-Federation
At the time of writing this I am on Function Version Id and Git Hash: 0955141

Not sure this is related to the problem, but I see you’re using the JsonConstructorAttribute on your object models

This doesn’t really fit with how this attribute is supposed to be used (see JsonConstructorAttribute)

And I’m not 100% sure what affect that would have on our custom serializer. (It should only really affect deserialization)

I’ll give your code a test tomorrow, see If I can debug the problem locally.

Thanks Jedd,

I have already tested removing all the attributes and I still got the above exception

1 Like

I have another function trying to do similar things but a bit simpler, I noticed that by adding this change I started to get exactly the same exception as the first function I referenced earlier:

Before I added this change the function ran however all the Geometry objects (like Lines/Breps/etc) were pushed to the other stream as Base objects (which is sort of expected I guess)

For reference, bumping the version of Speckle.Objects seems to have done the trick:

So I think there might be a bug in the automate specific version of Speckle.Objects

1 Like

Hey @sanchez,

there is nothing automate specific in the Speckle.Objects nuget, so if the upgrade fixed your issues, you shouldn’t face any drawbacks from it.

What the cause of the issue was, we can check with @Jedd

1 Like

Hi, I am having this same issue. Just going through the SDK guide to send data from the documentation.

Here’s my amazing console application:

using System.Collections.ObjectModel;
using Objects.BuiltElements;
using Speckle.Core.Api;
using Speckle.Core.Credentials;
using Speckle.Core.Models;
using Speckle.Core.Transports;

Base data = new Base();

// Loop from 0 to 9 and create a room with name
Collection<Room> rooms = new Collection<Room>();
for (int i = 0; i < 10; i++)
{
  Room room = new Room() {
    area = 100 * i,
    volume = 1000,
    name = "Room " + i
  };
}


string projectId = "myProjectId";

var serverInfo = new ServerInfo() { url = "https://myserver.speckle.xyz" };
var account = new Account() { serverInfo = serverInfo, token = "mytoken" };
var client = new Client(account);
var transport = new ServerTransport(account, projectId);

var objectId = await Operations.Send(data, new List<ITransport>() { transport });

Console.WriteLine("Object sent with id: " + objectId);

Anyone can help?

Googling the issue I discovered the BinaryFormatter is not trusted any longer so its disabled by default in .NET apps. So I had to explicitly enable it like so:

image

Now it works. :slight_smile: feeling unsafe tho…

2 Likes

Thanks for the report.
I was semi-aware of this issue, but not aware of this workaround (so kudos!) (or that Microsoft were now prohibiting binary serialization)

I’ll do some investigation our end to see if there’s an alternative to the binary formatter we use for our object hashing.

3 Likes

I have found this is also an inline version that works.

This is useful if you are polyglot notebooking, where no such project file exists.

AppContext.SetSwitch(
    "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization",
    true
);

CAVEAT - of course, we shouldn’t be doing this because of security - but I have sh*t to do.

2 Likes