fix(conformance): unwrap formae.Value wrappers in CreateUnmanagedResource#442
Open
naxty wants to merge 1 commit into
Open
fix(conformance): unwrap formae.Value wrappers in CreateUnmanagedResource#442naxty wants to merge 1 commit into
naxty wants to merge 1 commit into
Conversation
…urce
The discovery harness's CreateAllUnmanagedResources forwards the
evaluated PKL JSON to the plugin verbatim. The agent's apply path
runs resolver.ConvertToPluginFormat on properties first, which both
resolves resolvable references *and* collapses formae.Value wrappers
({"\$value": ..., "\$strategy": ..., "\$visibility": ...}) down to
their scalar payload. The harness only does the resolvable half, so
any field declared in PKL as
field = new formae.Value { value = "x"; strategy = "SetOnce" }
reaches the plugin as the wrapper object and the cloud API rejects it
when the field is typed against the inner scalar (real example, OVH:
[version] Given data is not valid for type cloud.kube.VersionEnum
(code: InvalidRequest)
— sent during kube-cluster discovery once 1.33 was relaxed in the PKL
to (String|formae.Value)? to support SetOnce).
Adds flattenFormaeValuesInProperties / flattenFormaeValueWalk that
recursively replace any object carrying "\$value" with that key's
payload, while leaving "\$res": true resolvable markers intact (those
are owned by resolveResolvablesInProperties). Wired into
CreateAllUnmanagedResources right after the resolvable pass so plugins
authored against the apply-path contract no longer have to re-implement
this in every Create.
naxty
added a commit
to platform-engineering-labs/formae-plugin-ovh
that referenced
this pull request
Apr 28, 2026
Sidesteps the conformance harness's missing Value-flatten step (fix is in flight at platform-engineering-labs/formae#442). Plain "1.34" is how the schema's (String|formae.Value)? union is consumed by every other test that does not need SetOnce semantics, and OVH's GET still echoes the full patch ("1.34.6-1") so Verify is unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The discovery harness's
CreateAllUnmanagedResourcesforwards the evaluated PKL JSON to the plugin verbatim. The agent's apply path runsresolver.ConvertToPluginFormaton properties first, which both resolves resolvable references and collapsesformae.Valuewrappers ({ "\$value": ..., "\$strategy": ..., "\$visibility": ... }) down to their scalar payload. The harness only does the resolvable half, so a field declared in PKL asreaches the plugin as the wrapper object and the cloud API rejects it when the field is typed against the inner scalar. Hit on OVH:
…sent the moment kube testdata was relaxed to
version: (String|formae.Value)?forSetOncesemantics.Change
flattenFormaeValuesInProperties/flattenFormaeValueWalkhelpers that recursively replace any object carrying\$valuewith that key's payload, while leaving\$res: trueresolvable markers intact (those are owned byresolveResolvablesInPropertiesand run before this).CreateAllUnmanagedResourcesimmediately after the resolvable pass — same point at which the apply path'sresolver.ConvertToPluginFormatwould have done both steps in one call.\$respreservation, and untouched plain JSON.After this lands, plugins authored against the apply-path contract no longer have to re-implement Value unwrapping in every Create. Will pair with a downstream consumer bump in formae-plugin-ovh.
Test plan
go test -run TestFlattenFormaeValueWalk ./pkg/plugin-conformance-testspasses locally[CreateOOB]VersionEnum failure should be gone