8000 encoding/protobuf: google.protobuf.Struct translates to closed struct · Issue #3960 · cue-lang/cue · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
encoding/protobuf: google.protobuf.Struct translates to closed struct #3960
Open
@rogpeppe

Description

@rogpeppe

What version of CUE are you using (cue version)?

250524b0d6e0a2d64e2be220d55334ef62d65df6

Does this issue reproduce with the latest stable release?

Yes

What did you do?

exec cue import -I . x.proto
exec cat x.cue
exec cue vet -c -d '#StructWrap' x.cue foo.json

-- foo.json --
{
	"x": {
		"something": true
	}
}
-- x.proto --
syntax = "proto3";

package something.v1;

import "google/protobuf/struct.proto";

message StructWrap {
  google.protobuf.Struct x = 1;
}

-- google/protobuf/struct.proto --
syntax = "proto3";

package google.protobuf;

option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
option go_package = "types";
option java_package = "com.google.protobuf";
option java_outer_classname = "StructProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";

message Struct {
  map<string, Value> fields = 1;
}

message Value {
  oneof kind {
    NullValue null_value = 1;
    double number_value = 2;
    string string_value = 3;
    bool bool_value = 4;
    Struct struct_value = 5;
    ListValue list_value = 6;
  }
}

enum NullValue {
  NULL_VALUE = 0;
}

message ListValue {
  repeated Value values = 1;
}

What did you expect to see?

A passing test. The google.protobuf.Struct type should allow non-empty structs, but does not.
It should be generating {...} not {}.

What did you see instead?

> exec cue import -I . x.proto
> exec cat x.cue
[stdout]
package v1

#StructWrap: {
	x?: {} @protobuf(1,google.protobuf.Struct)
}
> exec cue vet -c -d '#StructWrap' x.cue foo.json
[stderr]
x.something: field not allowed:
    ./foo.json:3:3
[exit status 1]
FAIL: /tmp/x.txtar:3: unexpected command failure

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0