1

I use Go (golang) as my programming language together with Protobuf3 (protoc-gen-validate)to define my PB messages and rpc methods.

Part of my message looks like that:

string xxxxxx = 1 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (validate.rules).string.pattern = "^[a-zA-Z]{32}$"
  ];

when I try to feed this string

lYcWymElsCfPnJBRGukvLLocTuCCFhgJ

back as a response to an rpc method

return &pb.Zzzzzzz{
        xxxxxxx:         ev.Xxxxx.mehthod() // <--- reflect.TypeOf() == string  value lYcWymElsCfPnJBRGukvLLocTuCCFhgJ,
    }, nil

, I get this error message from the protobuf validation:

embedded message failed validation | caused by: invalid y.x: value does not match regex pattern \"^[a-zA-Z]{32}$\";

I dont see where the prob is! Is there any case that the encoding is different?

panos
  • 328
  • 1
  • 4
  • 16
  • Have you confirmed the string is exactly what you think it is? No newline at the end, for example. – Tinkerer Aug 18 '23 at 13:58
  • No newline, whitespaces or char that need to be escaped – panos Aug 18 '23 at 14:10
  • Can you include more detail? A code sequence with which others can observe the failure you see? You are describing what you believe you are doing, but given the stated regexp does match the stated string, the details of what you are actually doing must be important. – Tinkerer Aug 18 '23 at 14:20
  • I updated the question but honestly I don't think that I miss something. I have a method which returns that above mentioned string in a pb.zzz object (generated by protoc) – panos Aug 18 '23 at 14:41
  • `regex` is only applied in protobuf and is what is written in the question's text. – panos Aug 19 '23 at 12:05

0 Answers0