GoogleCloudPlatform / GoogleCloudPlatform/esp-v2

ESPv2/v1 case sensitivity issue

Open
#726 8 comments 0 reactions 1 assignee Assigned to @qiwzhang View on GitHub
Dominant language
Go
Stars
307
Forks
185
Avg merge
14h 45m
Merged PRs (30d)
6

Description

Hi,

we are moving from ESPv1 to v2. Here we found that enums are handled differently in case of v2. As demonstration i tested this with a simple service echoing back following input request:

{"user":{"firstName": "aa","lastName": "bb", "status": "ACTIVE"}}

The field status is an enum like:

enum Status {
UNDEFINED = 0;
UNINITIALIZED = 1;
ACTIVE = 2;
LOCKED = 3;
}

While using ESPv1 it was not an issue that the caller sent "Active" instead of "ACTIVE" in ESPv2 you would get an error like:

{
"code": 400,
"message": "user.status: invalid value \"Active\" for type type.googleapis.com/endpoints.helloservice.User.Status"
}

One solution would be of course to force our calles to send the enums capitalized - however that can be difficult and long to achive as we have to be sure all our callers adhere to this.

**So the question is: is there any way to achive the same behaviour as with ESPv1?**

Technologies we use: Java 18, Spring Boot 2.6

Proto file:

syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.gp.grpc";

package endpoints.helloservice;

service HelloService {
rpc hello(HelloRequest) returns (HelloResponse);
}

message HelloRequest
{
User user = 1;
}

message User
{
string firstName = 1;
string lastName = 2;
Status status=3;

enum Status {
UNDEFINED = 0;
UNINITIALIZED = 1;
ACTIVE = 2;
LOCKED = 3;
}
}

message HelloResponse {
string greeting = 1;
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.