Skip to content

buffa-packaging generates incomplete google.api.mod.rs when package contains multiple files #105

@ariesdevil

Description

@ariesdevil

Version

  • protoc-gen-buffa: v0.5.2
  • protoc-gen-buffa-packaging: v0.5.2

Description

When the google.api package contains multiple proto files (e.g., field_behavior.proto, http.proto, annotations.proto, httpbody.proto), buffa-packaging generates all the individual .rs files correctly, but the aggregated google.api.mod.rs only includes field_behavior and silently omits the rest.

This causes downstream Rust compilation to fail with "file not found" or "unresolved import" errors for google.api.http, google.api.annotations, and google.api.httpbody.

buf.gen.yaml (relevant excerpt)

version: v2
plugins:
  - local: protoc-gen-buffa
    out: _gen/rs/src/proto
    opt: [views=true, json=true, register_types=false]
    include_imports: true
  - local: protoc-gen-buffa-packaging
    out: _gen/rs/src/proto
    strategy: all
    include_imports: true

Generated files

All source files are present under _gen/rs/src/proto/:

google.api.annotations.__ext.rs
google.api.annotations.__oneof.rs
google.api.annotations.__view_oneof.rs
google.api.annotations.__view.rs
google.api.annotations.rs
google.api.field_behavior.__ext.rs
google.api.field_behavior.__oneof.rs
google.api.field_behavior.__view_oneof.rs
google.api.field_behavior.__view.rs
google.api.field_behavior.rs
google.api.http.__ext.rs
google.api.http.__oneof.rs
google.api.http.__view_oneof.rs
google.api.http.__view.rs
google.api.http.rs
google.api.httpbody.__ext.rs
google.api.httpbody.__oneof.rs
google.api.httpbody.__view_oneof.rs
google.api.httpbody.__view.rs
google.api.httpbody.rs
google.api.mod.rs   <-- incomplete

Actual google.api.mod.rs

// @generated by buffa-codegen. DO NOT EDIT.

include!("google.api.field_behavior.rs");
#[allow(
    non_camel_case_types,
    dead_code,
    unused_imports,
    clippy::derivable_impls,
    clippy::match_single_binding,
    clippy::uninlined_format_args,
    clippy::doc_lazy_continuation,
    clippy::module_inception
)]
pub mod __buffa {
    #[allow(unused_imports)]
    use super::*;
    pub mod view {
        #[allow(unused_imports)]
        use super::*;
        include!("google.api.field_behavior.__view.rs");
        pub mod oneof {
            #[allow(unused_imports)]
            use super::*;
            include!("google.api.field_behavior.__view_oneof.rs");
        }
    }
    pub mod oneof {
        #[allow(unused_imports)]
        use super::*;
        include!("google.api.field_behavior.__oneof.rs");
    }
    pub mod ext {
        #[allow(unused_imports)]
        use super::*;
        include!("google.api.field_behavior.__ext.rs");
    }
}
#[doc(inline)]
pub use self::__buffa::ext::FIELD_BEHAVIOR;

Expected google.api.mod.rs

It should include all google.api.* stems that were generated, not just field_behavior:

include!("google.api.field_behavior.rs");
include!("google.api.http.rs");
include!("google.api.annotations.rs");
include!("google.api.httpbody.rs");
// ... plus corresponding __view / __oneof / __ext includes

Additional observation

buf generate also emits the following warning, which may be related to how buffa-packaging handles multi-file packages:

duplicate generated file name "google.api.mod.rs". 
Generation will continue without error here and drop the second occurrence of this file, 
but please raise an issue with the maintainer of the plugin.

This warning appears twice, suggesting protoc-gen-buffa-packaging may be invoked in a way that races or duplicates the mod.rs generation for the same package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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