Skip to content

Commit 91007c3

Browse files
authored
fix(client-policy): correct ensure_nonempty! error message format (#4491)
The `ensure_nonempty!` macro in `Meta::try_from` produces malformed error messages when a Resource identity field was empty. The original form `concat!(stringify!($name, "must not be empty"))` passes both `$name` and the literal `"must not be empty"` as a single token list to the `stringify!` macro, which then renders them as source text. The result is an error string like `<resource>, "must not be empty"` (comma and double quotes included), instead of `<resource> must not be empty`. The outer `concat!` wraps a single string, so it becomes a no-op. Fix this by stringifying only the identifier, then concatenating the suffix separately: `concat!(stringify!($name), " must not be empty")`. Signed-off-by: Alejandro Martinez Ruiz <amr@buoyant.io>
1 parent c597070 commit 91007c3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • linkerd/proxy/client-policy/src

linkerd/proxy/client-policy/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ pub mod proto {
564564
($($name:ident),+) => {
565565
$(
566566
if $name.is_empty() {
567-
return Err(InvalidMeta(concat!(stringify!($name, "must not be empty"))));
567+
return Err(InvalidMeta(concat!(stringify!($name), " must not be empty")));
568568
}
569569
)+
570570
}

0 commit comments

Comments
 (0)