Skip to content

Conversation

@aaronjeline
Copy link
Contributor

The default full_name() and type_url() implementations in the Name trait produce invalid type URLs when PACKAGE is empty.

Example:

#[derive(Clone, PartialEq, Debug, Default)]
struct Test {
    value: i32,
}

impl prost::Message for Test {
    // ... Message implementation ...
}

impl Name for Test {
    const PACKAGE: &'static str = "";
    const NAME: &'static str = "test";
    // Using default type_url()/full_name() implementation from Name trait
}

#[test]
fn empty_package_default_url_fails_roundtrip() {
  let type_url = Test::type_url();
  assert_eq!(type_url, "/.test"); // URL has leading dot
  TypeUrl::new(&type_url).unwrap(); // This panics
}

This will happen with any message type with PACKAGE = "" using the default type_url() implementation.

To fix, I adjusted the implementation of Name::full_name() to handle the special case of an empty package.

Let me know if you'd like me to adjust anything.

Changes the implementation of Name::full_name() so that
it produces valid urls via Name::type_url() if the package
is empty.
Copy link
Contributor

@jknovi jknovi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

Copy link
Contributor

@GlenDC GlenDC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as well.

@LucioFranco LucioFranco added this pull request to the merge queue Jan 10, 2026
Merged via the queue into tokio-rs:master with commit e42dcad Jan 10, 2026
17 checks passed
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.

5 participants