Skip to content

fix(conformance): unwrap formae.Value wrappers in CreateUnmanagedResource#442

Open
naxty wants to merge 1 commit into
mainfrom
fix/conformance-flatten-value
Open

fix(conformance): unwrap formae.Value wrappers in CreateUnmanagedResource#442
naxty wants to merge 1 commit into
mainfrom
fix/conformance-flatten-value

Conversation

@naxty

@naxty naxty commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Summary

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 a 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. Hit on OVH:

[CreateOOB] failed to create unmanaged resource: create plugin-sdk-test-kubeiprestriction-cluster failed:
[version] Given data is not valid for type cloud.kube.VersionEnum (code: InvalidRequest)

…sent the moment kube testdata was relaxed to version: (String|formae.Value)? for SetOnce semantics.

Change

  • New flattenFormaeValuesInProperties / flattenFormaeValueWalk helpers that recursively replace any object carrying \$value with that key's payload, while leaving \$res: true resolvable markers intact (those are owned by resolveResolvablesInProperties and run before this).
  • Wire it into CreateAllUnmanagedResources immediately after the resolvable pass — same point at which the apply path's resolver.ConvertToPluginFormat would have done both steps in one call.
  • Unit tests for the walker covering scalar wrappers, nested wrappers, wrappers carrying object payloads, \$res preservation, 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-tests passes locally
  • Conformance run against formae-plugin-ovh#40 with this version of the framework — the kube-cluster [CreateOOB] VersionEnum failure should be gone

…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.
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.

1 participant