postman-app-support icon indicating copy to clipboard operation
postman-app-support copied to clipboard

Pass type.googleapis.com/google.protobuf.StringValue to pb.Any

Open Alp4ka opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the tracker for existing similar issues and I know that duplicates will be closed

Describe the Issue

Hello!

Currently I'am having issues with passing a value to an Any field as a part of GRPC request. Here is my request described in postman window in JSON format:

{
    "filter": {
        "criteria_list": [
            {
                "FilterLabel": "PaymentID",
                "operator": "OPERATOR_EQUAL",
                "operand": {
                        "@type": "type.googleapis.com/google.protobuf.StringValue",
                        "value": "e664008e-5f12-42b5-a717-44f8a4601a7b"
                  }
            }
        ],
        "limit": "0",
        "offset": "0",
        "sort_list": [
            {
                "FilterLabel": "PaymentStatus",
                "sort_direction": "SORT_DIRECTION_ASCENDING"
            }
        ]
    }
}

"operand" field is "google/protobuf/any.proto.Any". So the idea to pass string values supposes that I pack type.googleapis.com/google.protobuf.StringValue into Any. An 'Any' field JSON representation looks like following:

{
    "@type": "type.googleapis.com/google.protobuf.StringValue",
    "value": "my_value"
}

So the problem is that i cannot pass UUID values into 'value' field since the postman UI shows next error:

String does not match the pattern of "^([a-zA-Z0-9+/]{4})*([a-zA-Z0-9+/]{2}(==)?|[a-zA-Z0-9+/]{3}=?)?$".
bytes

A string of base64, or an array of numbers between 0 and 255

, whilst I can still pass it via grpc client as usual. I'd really appreciate if you suggest workarounds for my case without changing contract for service.


Postman: Version11.5.0 UI version: 11.5.0-ui-240716-0437 Desktop platform version: 11.5.0 Architecture: arm64 OS platform: OS X 22.6.0

Steps To Reproduce

enum Operator {
  OPERATOR_UNSPECIFIED = 0;
  OPERATOR_EQUAL = 1;
  OPERATOR_LESS_THAN = 2;
  OPERATOR_GREATER_THAN = 3;
  OPERATOR_LESS_OR_EQUAL_THAN = 4;
  OPERATOR_GREATER_OR_EQUAL_THAN = 5;
  OPERATOR_NOT_EQUAL = 6;
  OPERATOR_IN = 7;
  OPERATOR_NOT_IN = 8;
}

enum SortDirection {
  SORT_DIRECTION_UNSPECIFIED = 0;
  SORT_DIRECTION_ASCENDING = 1;
  SORT_DIRECTION_DESCENDING = 2;
}

message Criteria {
  string filter_label = 1;
  Operator operator = 2;
  repeated google.protobuf.Any operand = 3;  // protolint:disable:this REPEATED_FIELD_NAMES_PLURALIZED
}

message Sort {
  string filter_label = 1;
  SortDirection direction = 2;
}

message Filter {
  repeated Criteria criteria_list = 1;
  repeated Sort sort_list = 2;
  int64 limit = 3;
  int64 offset = 4;
}

message ListRequest {
  Filter filter = 1;
}

Screenshots or Videos

No response

Operating System

macOS

Postman Version

11.5.0

Postman Platform

Postman App

User Account Type

Signed In User

Additional Context?

No response

Alp4ka avatar Jul 30 '24 15:07 Alp4ka

It's suggested to pass values in base64 encoding, but it makes much difficulties for testers and analysts. I've made a short pre-request script to base64-encode every ListRequest.filter.criteria_list.operand value, but it seems like I can't avoid Postman's warnings about the wrong contract.

Alp4ka avatar Jul 30 '24 18:07 Alp4ka

@appurva21 Hey! Recently noticed that Kreya client works well with this kind of fields:

Image

Alp4ka avatar Mar 26 '25 04:03 Alp4ka

@Alp4ka regular expression for a string in base64 format

TimurIskandarov avatar Oct 01 '25 00:10 TimurIskandarov

@Alp4ka regular expression for a string in base64 format

Yeah, and I guess it's unnecessary.

Alp4ka avatar Oct 01 '25 07:10 Alp4ka

This would work much better if postman just fully supported serialization deserialization of pb.Any (like Kreya). I see you started supporting google timestamps (👍🏼 ) is there any issue out there for pb.Any @appurva21 ?

williamohara avatar Oct 23 '25 23:10 williamohara

@Alp4ka @williamohara Thanks for bringing this up!

I acknowledge that the current experience with google.protobuf.Any fields isn't ideal. We'll get this sorted soon.

appurva21 avatar Oct 24 '25 06:10 appurva21

Hey everyone!

Thanks for reporting the issue and for your patience. The issue has been fixed in Postman v11.69.7. You should now be able to send @type along with the associated value keys in google.protobuf.Any fields.

Please update to the latest version to get the fix, and feel free to reopen this issue if you continue to experience any problems.

Image

ankurdengla avatar Oct 31 '25 12:10 ankurdengla