Skip to content

Keep unknown protobuf fields on every message #69

Closed

Description

@jonasz-lasut

0.5.0 keeps unknown fields on State and Resource (#31, #65). Every other message still drops them, and those are the messages Crossplane has added fields to.

What 0.5.0 keeps

A request and a response with field 999 appended to each message below, decoded into the 0.5.0 types and encoded again:

Unknown field on After decode and encode_to_vec
State, Resource kept
RunFunctionRequest, RequestMeta dropped
RunFunctionResponse, ResponseMeta, Result, Requirements, ResourceSelector dropped

The release notes give the limit and the reason for it, which is that a function doesn't return the other messages. That holds for a function that builds its own response. It doesn't hold for one that forwards the request to another function and returns a response it didn't build. function-wasm and function-oci (guestfn) do that with the module of each step. Through the SDK's types, a module built on a newer proto than the runtime wouldn't receive a new request field, and a new field it set in requirements wouldn't reach Crossplane, with no error either way. Their runtime forwards raw bytes beside the SDK's types for this reason.

function-sdk-go has no such limit: protobuf-go keeps unknown fields on every message by default.

Where Crossplane adds fields

Since the function API went v1 in August 2024, run_function.proto has gained these fields:

Date Field Commit
2025-03-13 ResourceSelector.namespace = 5 crossplane/crossplane@af13705
2025-07-07 RunFunctionResponse.output = 7 crossplane/crossplane@83055e3
2025-08-05 RunFunctionRequest.required_resources = 8, Requirements.resources = 2 crossplane/crossplane@782cc67, crossplane/crossplane@651245e
2026-01-15 RunFunctionRequest.required_schemas = 9, Requirements.schemas = 3 crossplane/crossplane@cc135de
2026-01-16 RequestMeta.capabilities = 2 crossplane/crossplane@8c368f6

None of them is on State or Resource. Every addition so far is in a message that drops unknown fields.

Proposal

Keep unknown fields on every message of the proto, as State and Resource do in sdk/src/proto/state.rs. Each message gets an unknown_fields field and a prost::Message impl whose fallback arm keeps the bytes. prost can't do it for generated code yet (tokio-rs/prost#2 and the opt-in tokio-rs/prost#1340 are open, and 0.14.6 is the latest release), so either someone writes the remaining messages by hand, or the codegen bin generates them the way state.rs is written.

It's breaking in the way 0.5.0 was: a struct literal that lists every field needs ..Default::default(). That makes it 0.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions