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

google.protobuf.Value field in request message breaks corresponding generated flattened method test #414

Closed
software-dov opened this issue May 12, 2020 · 4 comments · Fixed by #1056
Assignees
Labels
generator Bugs, features, and so forth pertaining to the generated client surface priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@software-dov
Copy link
Contributor

software-dov commented May 12, 2020

The following:

import "google/protobuf/struct.proto";
import "google/api/client.proto";

service MyService {
  option (google.api.default_host) = "my.example.com";

  rpc MyMethod(MethodRequest) returns (MethodResponse) {
  	/* option (google.api.method_signature) = "inputs,parameters"; */
    option (google.api.method_signature) = "parameter";
  }
}

message MethodRequest {
  google.protobuf.Value parameter = 1;
}

Yields the following error in the test_my_flattened_method generated unit test:

 assert args[0].parameter == struct.Value(null_value=struct.NullValue.NULL_VALUE)
E           AssertionError: assert None == null_value: NULL_VALUE\n
E            +  where None = parameters {\n  null_value: NULL_VALUE\n}\n.parameters
E            +  and   null_value: NULL_VALUE\n = <class 'google.protobuf.struct_pb2.Value'>(null_value=0)
E            +    where <class 'google.protobuf.struct_pb2.Value'> = struct.Value
E            +    and   0 = <google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper object at 0x7f85c7f3059
0>.NULL_VALUE                                                                                                 
E            +      where <google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper object at 0x7f85c7f30590>
 = struct.NullValue           
@software-dov software-dov added generator Bugs, features, and so forth pertaining to the generated client surface priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels May 12, 2020
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Aug 19, 2020
@arithmetic1728
Copy link
Collaborator

any updates as we are out of slo

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Nov 8, 2020
@hkdevandla hkdevandla removed the 🚨 This issue needs some love. label Dec 16, 2020
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Dec 17, 2020
@hkdevandla
Copy link
Member

Any updates on this?

@hkdevandla hkdevandla removed the 🚨 This issue needs some love. label Mar 18, 2021
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Mar 19, 2021
@parthea
Copy link
Contributor

parthea commented Jul 2, 2021

Hi @software-dov ,

I'm hitting this issue in googleapis/python-aiplatform#498 . See build log.

____________________________ test_predict_flattened ____________________________

    def test_predict_flattened():
        client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),)

        # Mock the actual call within the gRPC stub, and fake the request.
        with mock.patch.object(type(client.transport.predict), "__call__") as call:
            # Designate an appropriate return value for the call.
            call.return_value = prediction_service.PredictResponse()
            # Call the method with a truthy value for each flattened field,
            # using the keyword arguments to the method.
            client.predict(
                endpoint="endpoint_value",
                instances=[struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)],
                parameters=struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE),
            )

            # Establish that the underlying call was made with the expected
            # request object values.
            assert len(call.mock_calls) == 1
            _, args, _ = call.mock_calls[0]
            assert args[0].endpoint == "endpoint_value"
            assert args[0].instances == [
                struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)
            ]
>           assert args[0].parameters == struct_pb2.Value(
                null_value=struct_pb2.NullValue.NULL_VALUE
            )
E           assert None == null_value: NULL_VALUE\n
E            +  where None = endpoint: "endpoint_value"\ninstances {\n  null_value: NULL_VALUE\n}\nparameters {\n  null_value: NULL_VALUE\n}\n.parameters
E            +  and   null_value: NULL_VALUE\n = <class 'google.protobuf.struct_pb2.Value'>(null_value=0)
E            +    where <class 'google.protobuf.struct_pb2.Value'> = struct_pb2.Value
E            +    and   0 = <google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper object at 0x7f4fc6d44278>.NULL_VALUE
E            +      where <google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper object at 0x7f4fc6d44278> = struct_pb2.NullValue

@parthea parthea added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jul 2, 2021
@parthea
Copy link
Contributor

parthea commented Jul 10, 2021

Bumping back to p2 as I've re-added the workaround that was previously present.

@parthea parthea added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Jul 10, 2021
@software-dov software-dov linked a pull request Oct 29, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generator Bugs, features, and so forth pertaining to the generated client surface priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants