Skip to content

CreateNamespacedCustomObjectAsync unusable with AOT #1670

@IvanJosipovic

Description

@IvanJosipovic

Describe the bug
When using the Aot NuGet Package, we're unable to use CreateNamespacedCustomObjectAsync as we're not able to pass a custom JsonTypeInfo object.

System.AggregateException : One or more errors occurred. (Value cannot be null. (Parameter 'jsonTypeInfo'))
---- System.ArgumentNullException : Value cannot be null. (Parameter 'jsonTypeInfo')
   at System.Threading.Tasks.Task.Wait()
   at MyClass..ctor(Object, Span`1)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
----- Inner Stack Trace -----
   at System.ArgumentNullException.Throw(String paramName)
   at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName)
   at System.Text.Json.JsonSerializer.Serialize(Object value, JsonTypeInfo jsonTypeInfo)
   at k8s.KubernetesJson.Serialize(Object value, JsonSerializerOptions jsonSerializerOptions)
   at k8s.Kubernetes.SendRequest[T](String relativeUri, HttpMethod method, IReadOnlyDictionary`2 customHeaders, T body, CancellationToken cancellationToken)
   at k8s.AbstractKubernetes.ICustomObjectsOperations_CreateNamespacedCustomObjectWithHttpMessagesAsync[T](Object body, String group, String version, String namespaceParameter, String plural, String dryRun, String fieldManager, String fieldValidation, Nullable`1 pretty, IReadOnlyDictionary`2 customHeaders, CancellationToken cancellationToken)
   at k8s.AbstractKubernetes.k8s.ICustomObjectsOperations.CreateNamespacedCustomObjectWithHttpMessagesAsync(Object body, String group, String version, String namespaceParameter, String plural, String dryRun, String fieldManager, String fieldValidation, Nullable`1 pretty, IReadOnlyDictionary`2 customHeaders, CancellationToken cancellationToken)
   at k8s.CustomObjectsOperationsExtensions.CreateNamespacedCustomObjectAsync(ICustomObjectsOperations operations, Object body, String group, String version, String namespaceParameter, String plural, String dryRun, String fieldManager, String fieldValidation, Nullable`1 pretty, CancellationToken cancellationToken)

Kubernetes C# SDK Client Version
KubernetesClient.Aot 17.0.14

To Reproduce
Use CreateNamespacedCustomObjectAsync with the KubernetesClient.Aot library loaded.

Expected behavior
CreateNamespacedCustomObjectAsync should allow us to pass a custom JsonSerializerOptions or JsonTypeInfo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions