Skip to content

Bump Python function template to the SDK release with exclude_unset fix #79

@negz

Description

@negz

What problem are you facing?

The Python function template pins an old SDK that has a behaviour bug we've since fixed upstream.

When you scaffold a Python function the generated pyproject.toml depends on crossplane-function-sdk-python==0.11.0 (see pyproject.toml.tmpl). That version serializes composed resources with model_dump(exclude_defaults=True), which doesn't play well with the models crossplane project build now generates.

The background is in #64, where we bumped the pinned datamodel-code-generator image. The newer generator emits a field with an object default as a raw dict plus validate_default=True rather than a default_factory. Under exclude_defaults that means an unset field like spec.providerConfigRef no longer compares equal to its declared default, so it leaks into every composed resource — every Upbound GCP/AWS resource ends up with an explicit spec.providerConfigRef: {kind: ClusterProviderConfig, name: default} it previously omitted. The full analysis is in function-sdk-python#207.

The SDK fix is function-sdk-python#208, which switches to exclude_unset. That serializes only the fields a function actually set, which is the right question to ask for server-side apply intent, and it's immune to however the generator chooses to represent a default. It's merged but not released yet — the latest SDK release is v0.12.0, so the fix will land in the next one, which should be v0.13.0.

How could Crossplane help solve your problem?

Once the SDK release with function-sdk-python#208 is out, bump the pinned version in the Python function template from 0.11.0 to it (v0.13.0, assuming that's the next release). That's the one spot in pyproject.toml.tmpl, so newly scaffolded functions get the corrected serialization behaviour by default.

This is a reminder to come back once the SDK ships; we should confirm the exact version then.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions