Skip to content

Conversation

@pfeifferj
Copy link

@pfeifferj pfeifferj commented Oct 23, 2025

Instance provisioning fails with "Expected only one oneOf fields to be set: got 0" errors when using InstancePrototype types with interface-typed fields.

Go's default JSON marshaling omits interface-typed fields in certain contexts. oneOf discriminator fields (image, zone, vpc, primary_network_attachment) are missing from the JSON payload, causing VPC API validation to fail.

This commit adds custom MarshalJSON methods to 8 InstancePrototype variant types that explicitly serialize all fields including interface types.

Fixes: #133

@pfeifferj pfeifferj force-pushed the fix/instance-prototype-json-marshaling branch from 2ea40fe to 4c6e54c Compare October 23, 2025 19:46
…fields

Instance provisioning fails with "Expected only one oneOf fields to be set:
got 0" errors when using InstancePrototype types with interface-typed fields.

Go's default JSON marshaling omits interface-typed fields in certain contexts.
oneOf discriminator fields (image, zone, vpc, primary_network_attachment) are
missing from the JSON payload, causing VPC API validation to fail.

This commit adds custom MarshalJSON methods to all InstancePrototype variant
types that explicitly serialize all fields including interface types.

Adds MarshalJSON() method requirement to InstancePrototypeIntf interface.
This only affects code that implements this interface (SDK-generated types
already comply).

Fixes: IBM#133
Signed-off-by: Josephine Pfeiffer <[email protected]>
@pfeifferj pfeifferj force-pushed the fix/instance-prototype-json-marshaling branch from 4c6e54c to d51de4a Compare October 24, 2025 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InstancePrototype oneOf Constraint Validation Failure

1 participant