Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid handling of enum values #120

Closed
ocherniavskyi-lohika-tix opened this issue Jul 28, 2022 · 2 comments
Closed

Invalid handling of enum values #120

ocherniavskyi-lohika-tix opened this issue Jul 28, 2022 · 2 comments

Comments

@ocherniavskyi-lohika-tix
Copy link

ocherniavskyi-lohika-tix commented Jul 28, 2022

We have next service described in proto:


service AssetsService {
    rpc GetAssetMetadataByType (AssetMetadataRequest) returns (AssetMetadataResponse);
}

message AssetMetadataRequest {
  AssetType assetType = 1;
  string moduleId = 2;
  string version = 3;
}

message AssetMetadataResponse {
  repeated AssetMetadataDto assetMetadata = 1;
}

message AssetMetadataDto {
  reserved 7;
  string fieldName = 1;
  AssetFieldType fieldType = 2;
  bool mandatory = 3;
  string displayName = 4;
  bool system = 5;
  string fieldDescription = 6;  
}

enum AssetType {
  PURCHASE_ORDER = 0;
  INVOICE = 1;
  LOGISTIC = 2;
  EIPU = 3;
}

When i creating stub like this:

{
   "service":"AssetsService",
   "method":"GetAssetMetadataByType",
   "input":{
      "equals":{
         "assetType":0,
         "moduleId":"2DBF501378694CE1AC41294146286F3F",
         "version":"2.5"
      }
   },
   "output":{
      "data":{
         "assetMetadata":[
            {
               "fieldName":"foo",
               "fieldType":"STRING",
               "mandatory":true,
               "displayName":"fooo",
               "system":false,
               "fieldDescription":"some descr",
            }
         ]
      }
   }
}

And call method GetAssetMetadataByType with enum value PURCHASE_ORDER(means "0") : gripmock failed to match request with failure:

Input

{
	moduleId: 2DBF501378694CE1AC41294146286F3F
	version: 2.5
}

Closest Match 

equals:{
	assetType: 0
	moduleId: 2DBF501378694CE1AC41294146286F3F
	version: 2.5
}

but when im changing enum value in grpc request - from PURCHASE_ORDER to INVOICE (means "1") then error is next:

Input

{
        assetType: 1
	moduleId: 2DBF501378694CE1AC41294146286F3F
	version: 2.5
}

Closest Match 

equals:{
	assetType: 0
	moduleId: 2DBF501378694CE1AC41294146286F3F
	version: 2.5
}

So seems 0 as enum index is the root cause of this issue.

@ocherniavskyi-lohika-tix
Copy link
Author

duplicate of 107

@manu1993
Copy link

Any updates on this? I am seeing the same error?

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

No branches or pull requests

2 participants