Skip to content

feat(proto)!: keep unknown State/Resource fields - #65

Merged
jonasz-lasut merged 2 commits into
mainfrom
feat/keep-unknown-fields
Nov 19, 2026
Merged

jonasz-lasut merged 2 commits into
mainfrom
feat/keep-unknown-fields

Conversation

@jonasz-lasut

@jonasz-lasut jonasz-lasut commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

State and Resource are now written by hand in sdk/src/proto/state.rs, with a prost::Message impl that keeps fields it doesn't know and writes them back on encode. A field a newer Crossplane adds to desired state then passes through response::to as it does in function-sdk-go. Codegen skips both messages with extern_path and initializes the new unknown_fields field in their generated serde constructors. The tests compare the hand-written encoding with prost-derived copies of both messages, and one fails when the vendored proto changes either message.

This is a breaking change, so the next release is 0.5.0: a State or Resource struct literal that lists every field needs ..Default::default(), and their Debug output includes unknown_fields.

The first commit fixes two Cargo.lock entries that named syn 3.0.4, a version the lockfile no longer has. cargo build --locked failed on main because of them.

Fixes #31

Two lockfile updates merged without a rebase left entries that name
syn 3.0.4, a version the lockfile no longer has. Cargo rewrote them on
every build, and cargo build --locked failed.

Signed-off-by: Jonasz Małecki <jonasz@upbound.io>
@jonasz-lasut
jonasz-lasut force-pushed the feat/keep-unknown-fields branch from 43d5434 to c555d88 Compare November 19, 2026 08:39
@jonasz-lasut jonasz-lasut changed the title feat(proto): keep unknown fields on State and Resource feat(proto)!: keep unknown State/Resource fields Nov 19, 2026
prost discards fields it does not know, so a function built on this SDK
stripped any field a newer Crossplane adds to the desired state it
copies forward with response::to. function-sdk-go keeps such fields.

Write State and Resource by hand with a prost::Message impl that
decodes and encodes known fields as the generated one does, keeps
unknown fields, and writes them back on encode. Codegen skips both
messages through extern_path and initializes the new field in their
serde constructors.

BREAKING CHANGE: State and Resource have a new public unknown_fields
field. Struct literals and patterns that list every field no longer
compile; add ..Default::default() or `..`. Their Debug output includes
unknown_fields.

Fixes #31

Signed-off-by: Jonasz Małecki <jonasz@upbound.io>
@jonasz-lasut
jonasz-lasut force-pushed the feat/keep-unknown-fields branch from c555d88 to 5870678 Compare November 19, 2026 08:50
@jonasz-lasut
jonasz-lasut marked this pull request as ready for review November 19, 2026 08:59
@jonasz-lasut
jonasz-lasut merged commit 63c4dcd into main Nov 19, 2026
5 checks passed
@jonasz-lasut
jonasz-lasut deleted the feat/keep-unknown-fields branch November 19, 2026 09:02
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.

Pass-through drops unknown protobuf fields that function-sdk-go keeps

1 participant