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

Output values do not serialize to the same objects as they deserialize from #377

Open
jkerken opened this issue Nov 11, 2024 · 1 comment
Labels
kind/enhancement Improvements or new features

Comments

@jkerken
Copy link
Contributor

jkerken commented Nov 11, 2024

So we may have an edge usecase that show some intressing beauvoirs for the serialiazation.
For Context: We have a MLC c# provider that uses the sdk generator classes as the actual output objects in the components provider implementations, to be sure our output and the schema stay in sync.
We also use c# for the consuming side with the exact same sdk.

Now the actual issues are the generator output classes, they look like this:

    [OutputType]
    public sealed class DatacenterOutput
    {
        public readonly string Name;

        [OutputConstructor]
        private DatacenterOutput(string name)
          Name = name;
        }
    }
}

The problem is now they get serialized like:

{ 
   "Name": "someValue"
}

But then the deserialization takes the names of the properties from the Output Contructors arguments names

So the expected value is now

{
   "name":"someValue"
}

Since this does not match up. The client side sets all fields to null and then the programm crashes since they were not optional.

There are now two worarounds: Adding [Output( Name = "name"] to the property or [OutputConstructorParameter("Name")] on the constructor.

Bot both would require you to modify the generated.

I am happy to work on a fix, but I am really unsure how/where this is actually to be fixed. So wanted to gather some feedback on this bug.

@pulumi-bot pulumi-bot added the needs-triage Needs attention from the triage team label Nov 11, 2024
@justinvp justinvp added kind/enhancement Improvements or new features and removed needs-triage Needs attention from the triage team labels Nov 16, 2024
@justinvp
Copy link
Member

What you're trying to do generally makes sense (using the generated SDK so it's in sync with the schema), but the output classes weren't intended to be serialized in this way -- they're really just meant to be targets of deserialization. Typically, there would be an associated input class that can be serialized correctly.

Note: We're currently looking into making it easier to create "MLC"s, but with little-to-no provider boilerplate and automatic schema creation from your component definition in C#. So rather than using the generated SDK in your component provider implementation, we'd drive schema generation from your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

3 participants