Bump Python function template to the SDK release with exclude_unset fix
- Dominant language
- Go
- Stars
- 19
- Forks
- 31
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 52
Description
### 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`](https://github.com/crossplane/cli/blob/main/cmd/crossplane/function/templates/python/pyproject.toml.tmpl#L12)). 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](https://github.com/crossplane/cli/pull/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](https://github.com/crossplane/function-sdk-python/issues/207).
The SDK fix is [function-sdk-python#208](https://github.com/crossplane/function-sdk-python/pull/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](https://github.com/crossplane/function-sdk-python/pull/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`](https://github.com/crossplane/cli/blob/main/cmd/crossplane/function/templates/python/pyproject.toml.tmpl#L12), 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.
Contributor guide
Assessment
This issue has not been assessed yet.