grpc-test

module
v0.0.0-...-2e6664b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2023 License: Apache-2.0

README

grpc-test

gRPC test service

problem repro for protovalidate RegEx \S failure

Using matches with a RegEx \S not whitespace fails with a compile expression failure while using the semantic equivalent [^\t\n\f\r ] works correctly.

According to the RegEx documentation CEL, this should be supported as part of the supported RE2 syntax (https://github.com/google/re2/wiki/Syntax)

Using \S failure

    (buf.validate.field) = {
        required: true,
        cel: {
            id: "hello_request_name"
            message: "cannot contain any spaces or other whitespace characters"
            expression: "this.matches('^[^\\S]+$')"
        }
        string: {
            max_len: 256
        }
    }

Failure output

ERROR:
  Code: Unknown
  Message: compilation error: failed to compile expression hello_request_name: ERROR: <input>:1:14: Syntax error: token recognition error at: ''^[^\S'
 | this.matches('^[^\S]+$')
 | .............^
ERROR: <input>:1:20: Syntax error: mismatched input ']' expecting {'[', '{', '(', ')', '.', '-', '!', 'true', 'false', 'null', NUM_FLOAT, NUM_INT, NUM_UINT, STRING, BYTES, IDENTIFIER}
 | this.matches('^[^\S]+$')
 | ...................^
ERROR: <input>:1:22: Syntax error: token recognition error at: '$'
 | this.matches('^[^\S]+$')
 | .....................^
ERROR: <input>:1:23: Syntax error: token recognition error at: '')'
 | this.matches('^[^\S]+$')
 | ......................^
ERROR: <input>:1:25: Syntax error: mismatched input '<EOF>' expecting {'[', '{', '(', '.', '-', '!', 'true', 'false', 'null', NUM_FLOAT, NUM_INT, NUM_UINT, STRING, BYTES, IDENTIFIER}
 | this.matches('^[^\S]+$')
 | ........................^
make: *** [run-client-failed] Error 66

Semantic equivalent:

    (buf.validate.field) = {
        required: true,
        cel: {
            id: "hello_request_name"
            message: "cannot contain any spaces or other whitespace characters"
            expression: "this.matches('^[^\\t\\n\\f\\r ]+$')"
        }
        string: {
            max_len: 256
        }
    }

Expected output

ERROR:
  Code: Unknown
  Message: validation error:
 - name: cannot contain any spaces or other whitespace characters [hello_request_name]
make: *** [run-client-success] Error 66

Directories

Path Synopsis
Package helloworld is a reverse proxy.
Package helloworld is a reverse proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL