Skip to content

ViewNameConflict: codegen fails when message FooView exists alongside message Foo #32

@th0114nd

Description

@th0114nd

Summary

buffa-build returns a ViewNameConflict error when a proto package contains both a message Foo and a message FooView, because buffa generates a view type named FooView for message Foo that collides with the user-defined FooView message.

This is valid protobuf. The workaround is .generate_views(false), but that disables views for the entire crate.

Minimal reproducer

syntax = "proto3";

package test;

message Warning {
  string text = 1;
}

message WarningView {
  string text = 1;
  int32 severity = 2;
}
// build.rs
fn main() {
    buffa_build::Config::new()
        .files(&["view_conflict.proto"])
        .includes(&["."])
        .compile()
        .unwrap();
}

Error

ViewNameConflict { scope: "test", owned_msg: "Warning", view_msg: "WarningView" }

Expected behavior

Code generation should succeed. The generated view type for Warning could be disambiguated — for example by renaming it on conflict to WarningBorrowView, WarningRef, or placing it in a sub-module.

Impact

Low — in a ~7k proto file corpus this only affected 2 packages. The per-crate .generate_views(false) workaround is sufficient, but it would be nice to not lose views for those crates.

Version

buffa 0.3.0 (built from source, main branch)

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