Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,31 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

## [Unreleased]

## [0.5.2] - 2026-05-07

### Fixed

- **`buffa-codegen`: oneof `Serialize` match arms now use `Self::#variant`.**
`generate_oneof_serialize` emits the manual JSON serde impl as
`impl Serialize for #enum_ident { fn serialize(&self, …) { match self { … } } }`,
where `Self` resolves to the oneof enum. The match arms used the
fully-qualified `#enum_ident::#variant` form, which trips
`clippy::use_self` in workspaces that opt it on — particularly visible
under `connectrpc-build`, which doesn't carry an inner `#![allow(...)]`
the way `protoc-gen-buffa-packaging` does, so the oneof companion file
inherits the surrounding mod's lint set. The deserialize arms in
`oneof_variant_deser_arm` remain qualified because they construct the
oneof from inside the *message*'s `Deserialize` impl, where `Self` would
be wrong. No behavioural change.
- **`buffa-codegen`: enum JSON deserialize errors use inlined format args.**
The enum visitor's range-check and unknown-value error messages used
positional `format!("enum value {} out of i32 range", v)` etc., which
trip `clippy::uninlined_format_args` for the same reason as above (the
enum impls live in the per-proto Owned content, outside the `__buffa`
`#[allow(...)]` block). Now `format!("enum value {v} out of i32
range")` etc. — semantically identical, lint-clean regardless of which
module wrapper covers it.

## [0.5.1] - 2026-05-07

### Fixed
Expand Down
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exclude = [
]

[workspace.package]
version = "0.5.1"
version = "0.5.2"
edition = "2021"
rust-version = "1.85"
license = "Apache-2.0"
Expand All @@ -33,12 +33,12 @@ keywords = ["protobuf", "protocol-buffers", "serialization", "no-std", "editions
categories = ["encoding", "no-std"]

[workspace.dependencies]
buffa = { path = "buffa", version = "0.5.1", default-features = false }
buffa-types = { path = "buffa-types", version = "0.5.1" }
buffa-descriptor = { path = "buffa-descriptor", version = "0.5.1" }
buffa-codegen = { path = "buffa-codegen", version = "0.5.1" }
buffa-build = { path = "buffa-build", version = "0.5.1" }
buffa-test = { path = "buffa-test", version = "0.5.1" }
buffa = { path = "buffa", version = "0.5.2", default-features = false }
buffa-types = { path = "buffa-types", version = "0.5.2" }
buffa-descriptor = { path = "buffa-descriptor", version = "0.5.2" }
buffa-codegen = { path = "buffa-codegen", version = "0.5.2" }
buffa-build = { path = "buffa-build", version = "0.5.2" }
buffa-test = { path = "buffa-test", version = "0.5.2" }
base64 = { version = "0.22", default-features = false, features = ["alloc"] }
bytes = { version = "1", default-features = false }
hashbrown = { version = "0.15", default-features = false, features = ["default-hasher"] }
Expand Down
2 changes: 1 addition & 1 deletion buffa-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ categories = ["development-tools::build-utils"]
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
buffa = { path = "../buffa", version = "0.5.1" }
buffa = { path = "../buffa", version = "0.5.2" }
buffa-codegen = { workspace = true }
tempfile = "3"
2 changes: 1 addition & 1 deletion buffa-codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ categories = ["development-tools::build-utils"]

[dependencies]
# `path` wins for local workspace development; `version` is used on publish.
buffa = { path = "../buffa", version = "0.5.1" }
buffa = { path = "../buffa", version = "0.5.2" }
buffa-descriptor = { workspace = true }
prettyplease = { workspace = true }
proc-macro2 = { workspace = true }
Expand Down
8 changes: 4 additions & 4 deletions buffa-codegen/src/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@ fn generate_enum_serde(name_ident: &Ident) -> TokenStream {
fn visit_i64<E: ::serde::de::Error>(self, v: i64) -> ::core::result::Result<#name_ident, E> {
let v32 = i32::try_from(v).map_err(|_| {
::serde::de::Error::custom(
::buffa::alloc::format!("enum value {} out of i32 range", v)
::buffa::alloc::format!("enum value {v} out of i32 range")
)
})?;
<#name_ident as ::buffa::Enumeration>::from_i32(v32).ok_or_else(|| {
::serde::de::Error::custom(
::buffa::alloc::format!("unknown enum value {}", v32)
::buffa::alloc::format!("unknown enum value {v32}")
)
})
}

fn visit_u64<E: ::serde::de::Error>(self, v: u64) -> ::core::result::Result<#name_ident, E> {
let v32 = i32::try_from(v).map_err(|_| {
::serde::de::Error::custom(
::buffa::alloc::format!("enum value {} out of i32 range", v)
::buffa::alloc::format!("enum value {v} out of i32 range")
)
})?;
<#name_ident as ::buffa::Enumeration>::from_i32(v32).ok_or_else(|| {
::serde::de::Error::custom(
::buffa::alloc::format!("unknown enum value {}", v32)
::buffa::alloc::format!("unknown enum value {v32}")
)
})
}
Expand Down
13 changes: 10 additions & 3 deletions buffa-codegen/src/oneof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,18 @@ fn generate_oneof_serialize(
let ident = &v.variant_ident;
let json_name = &v.json_name;

// These arms live inside `impl Serialize for #enum_ident { fn
// serialize(&self, ..) { match self { .. } } }`, so `Self`
// resolves to the oneof enum and is the idiomatic spelling
// (rustc's `clippy::use_self` flags the qualified form).
// Contrast `oneof_variant_deser_arm` below, whose constructor
// calls run inside the *message*'s Deserialize impl where
// `Self` would be wrong.
if v.is_null_value {
// NullValue must serialize as JSON `null`, not "NULL_VALUE".
// `&()` serializes as JSON `null` via serde_json.
return quote! {
#enum_ident::#ident(_) => {
Self::#ident(_) => {
map.serialize_entry(#json_name, &())?;
}
};
Expand All @@ -345,7 +352,7 @@ fn generate_oneof_serialize(
// Type needs special proto JSON encoding — wrap in a newtype
// that delegates to the helper's serialize function.
quote! {
#enum_ident::#ident(v) => {
Self::#ident(v) => {
struct _W<'a>(&'a #rust_type);
impl serde::Serialize for _W<'_> {
fn serialize<S2: serde::Serializer>(&self, s: S2) -> ::core::result::Result<S2::Ok, S2::Error> {
Expand All @@ -357,7 +364,7 @@ fn generate_oneof_serialize(
}
} else {
quote! {
#enum_ident::#ident(v) => {
Self::#ident(v) => {
map.serialize_entry(#json_name, v)?;
}
}
Expand Down
20 changes: 10 additions & 10 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,25 +295,25 @@ Download the binaries for your platform from the [releases page](https://github.

```sh
# Download binaries + cosign signatures + certificates (both plugins match)
gh release download v0.5.1 --repo anthropics/buffa \
gh release download v0.5.2 --repo anthropics/buffa \
--pattern 'protoc-gen-buffa*-linux-x86_64*'

# Verify with GitHub attestations (requires gh CLI ≥ 2.49)
gh attestation verify protoc-gen-buffa-v0.5.1-linux-x86_64 --repo anthropics/buffa
gh attestation verify protoc-gen-buffa-packaging-v0.5.1-linux-x86_64 --repo anthropics/buffa
gh attestation verify protoc-gen-buffa-v0.5.2-linux-x86_64 --repo anthropics/buffa
gh attestation verify protoc-gen-buffa-packaging-v0.5.2-linux-x86_64 --repo anthropics/buffa

# Or with cosign (standalone, no gh required) — shown for one binary
cosign verify-blob \
--signature protoc-gen-buffa-v0.5.1-linux-x86_64.sig \
--certificate protoc-gen-buffa-v0.5.1-linux-x86_64.pem \
--signature protoc-gen-buffa-v0.5.2-linux-x86_64.sig \
--certificate protoc-gen-buffa-v0.5.2-linux-x86_64.pem \
--certificate-identity-regexp "github.com/anthropics/buffa" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
protoc-gen-buffa-v0.5.1-linux-x86_64
protoc-gen-buffa-v0.5.2-linux-x86_64

# Install both
chmod +x protoc-gen-buffa-v0.5.1-linux-x86_64 protoc-gen-buffa-packaging-v0.5.1-linux-x86_64
mv protoc-gen-buffa-v0.5.1-linux-x86_64 ~/.local/bin/protoc-gen-buffa
mv protoc-gen-buffa-packaging-v0.5.1-linux-x86_64 ~/.local/bin/protoc-gen-buffa-packaging
chmod +x protoc-gen-buffa-v0.5.2-linux-x86_64 protoc-gen-buffa-packaging-v0.5.2-linux-x86_64
mv protoc-gen-buffa-v0.5.2-linux-x86_64 ~/.local/bin/protoc-gen-buffa
mv protoc-gen-buffa-packaging-v0.5.2-linux-x86_64 ~/.local/bin/protoc-gen-buffa-packaging
```

Available platforms: `linux-x86_64`, `linux-aarch64`, `darwin-x86_64`, `darwin-aarch64`, `windows-x86_64` (`.exe`). All releases include SHA-256 checksums, Sigstore cosign signatures, and signed SLSA build provenance for supply chain verification.
Expand Down Expand Up @@ -369,7 +369,7 @@ Plugin options (passed via `opt:`):
```yaml
version: v2
plugins:
- remote: buf.build/anthropic/buffa:v0.5.1
- remote: buf.build/anthropic/buffa:v0.5.2
out: src/generated
opt: [views=true]
```
Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-buffa-packaging/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ keywords = ["protobuf", "protocol-buffers", "protoc", "plugin", "codegen"]
categories = ["development-tools::build-utils", "command-line-utilities"]

[dependencies]
buffa = { path = "../buffa", version = "0.5.1" }
buffa = { path = "../buffa", version = "0.5.2" }
buffa-codegen = { workspace = true }
2 changes: 1 addition & 1 deletion protoc-gen-buffa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ keywords = ["protobuf", "protocol-buffers", "protoc", "plugin", "codegen"]
categories = ["development-tools::build-utils", "command-line-utilities"]

[dependencies]
buffa = { path = "../buffa", version = "0.5.1" }
buffa = { path = "../buffa", version = "0.5.2" }
buffa-codegen = { workspace = true }
Loading