Skip to content
This repository was archived by the owner on Aug 25, 2026. It is now read-only.
This repository was archived by the owner on Aug 25, 2026. It is now read-only.

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

Closed

Description

@software-dov

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           

Activity

  1. added
    generatorBugs, features, and so forth pertaining to the generated client surface
    priority: p2Moderately-important priority. Fix may not be included in next release.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on May 12, 2020
  2. added
    🚨This issue needs some love.
    and removed
    🚨This issue needs some love.
    on Aug 19, 2020
  3. arithmetic1728 commented on Oct 13, 2020

    @arithmetic1728
    Contributor

    any updates as we are out of slo

  4. hkdevandla commented on Dec 29, 2020

    @hkdevandla

    Any updates on this?

  5. parthea commented on Jul 2, 2021

    @parthea
    Contributor

    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
    
  6. added
    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.
    and removed
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Jul 2, 2021
  7. parthea commented on Jul 10, 2021

    @parthea
    Contributor

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

  8. added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    and removed
    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.
    on Jul 10, 2021
  9. linked a pull request that will close this issuefeat: add fragment tests #1056on Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.generatorBugs, features, and so forth pertaining to the generated client surfacepriority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions