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

Library unit test failing with struct_pb2.Value #410

@dizcology

Description

@dizcology

Generate library with the following service proto:

// put this file in google/cloud/myservice/v1/

syntax = "proto3";

package myservice.v1;

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";
  }
}

message MethodRequest {
  repeated google.protobuf.Value inputs = 1;
  google.protobuf.Value parameters = 2;
}

message MethodResponse {
  repeated google.protobuf.Value outputs = 1;
}

The generated unit test fails with:

# Merge in the value being set.
        if pb_value is not None:
>           self._pb.MergeFrom(self._meta.pb(**{key: pb_value}))
E           TypeError: Value must be iterable

Variant: commenting out the repeated inputs field, the generated unit test fails with a different error:

_, args, _ = call.mock_calls[0]
>           assert args[0].parameters == 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 0x10ac9ce50>.NULL_VALUE
E            +      where <google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper object at 0x10ac9ce50> = struct.NullValue

Metadata

Metadata

Assignees

Labels

triage meI really want to be triaged.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions