golang / protobuf

Go support for Google's protocol buffers
BSD 3-Clause "New" or "Revised" License
9.8k stars 1.58k forks source link

related to #1054 and similar "plugin output is unparseable" errors #1622

Closed jonasbadstuebner closed 5 months ago

jonasbadstuebner commented 5 months ago

Hello,

I am getting a plugin output is unparseable error and I am really stuck. I know that the dart plugin is not supported by this repository here, but I wanted to ask for some help with debugging the issue, since I don't even know, why it is not working. Can someone guide me to how I could debug what is actually wrong with the output of the plugin?

protoc seems to not have great debugging options.

I can generate Java code with no problem, but I don't know why this works and the dart plugin does not work. Somewhere inside protoc something is failing and I cannot tell, why or what. Is there a way to "look inside" protoc and know at which point it is actually dying?

jonasbadstuebner commented 5 months ago

Failed to parse input is also an error I can produce at will by dumping the binary output into a protoc --decode_raw with the dart plugin. If this helps?

jonasbadstuebner commented 5 months ago

test with protoc -I=lib/protos --dart_out="grpc:lib/protos/" lib/protos/google/protobuf/empty.proto --plugin=$HOME/.pub-cache/bin/protoc-gen-dart

output ``` --dart_out: protoc-gen-dart: Plugin output is unparseable: \020\001z\346\023\n\035google/protobuf/empty.pb.dartz\304\023//\n// Generated code. Do not modify.\n// source: google/protobuf/empty.proto\n//\n// @dart = 2.12\n\n// ignore_for_file: annotate_overrides, camel_case_types, comment_references\n// ignore_for_file: constant_identifier_names, library_prefixes\n// ignore_for_file: non_constant_identifier_names, prefer_final_fields\n// ignore_for_file: unnecessary_import, unnecessary_this, unused_import\n\nimport \'dart:core\' as $core;\n\nimport \'package:protobuf/protobuf.dart\' as $pb;\n\nexport \'package:protobuf/protobuf.dart\' show GeneratedMessageGenericExtensions;\n\n/// A generic empty message that you can re-use to avoid defining duplicated\n/// empty messages in your APIs. A typical example is to use it as the request\n/// or the response type of an API method. For instance:\n///\n/// service Foo {\n/// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);\n/// }\nclass Empty extends $pb.GeneratedMessage {\n factory Empty() => create();\n Empty._() : super();\n factory Empty.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);\n factory Empty.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);\n\n static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? \'\' : \'Empty\', package: const $pb.PackageName(_omitMessageNames ? \'\' : \'google.protobuf\'), createEmptyInstance: create)\n ..hasRequiredFields = false\n ;\n\n @$core.Deprecated(\n \'Using this can add significant overhead to your binary. \'\n \'Use [GeneratedMessageGenericExtensions.deepCopy] instead. \'\n \'Will be removed in next major version\')\n Empty clone() => Empty()..mergeFromMessage(this);\n @$core.Deprecated(\n \'Using this can add significant overhead to your binary. \'\n \'Use [GeneratedMessageGenericExtensions.rebuild] instead. \'\n \'Will be removed in next major version\')\n Empty copyWith(void Function(Empty) updates) => super.copyWith((message) => updates(message as Empty)) as Empty;\n\n $pb.BuilderInfo get info_ => _i;\n\n @$core.pragma(\'dart2js:noInline\')\n static Empty create() => Empty._();\n Empty createEmptyInstance() => create();\n static $pb.PbList createRepeated() => $pb.PbList();\n @$core.pragma(\'dart2js:noInline\')\n static Empty getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create);\n static Empty? _defaultInstance;\n}\n\n\nconst _omitMessageNames = $core.bool.fromEnvironment(\'protobuf.omit_message_names\');\nz\245\003\n!google/protobuf/empty.pbenum.dartz\377\002//\n// Generated code. Do not modify.\n// source: google/protobuf/empty.proto\n//\n// @dart = 2.12\n\n// ignore_for_file: annotate_overrides, camel_case_types, comment_references\n// ignore_for_file: constant_identifier_names, library_prefixes\n// ignore_for_file: non_constant_identifier_names, prefer_final_fields\n// ignore_for_file: unnecessary_import, unnecessary_this, unused_import\n\nz\217\006\n!google/protobuf/empty.pbjson.dartz\351\005//\n// Generated code. Do not modify.\n// source: google/protobuf/empty.proto\n//\n// @dart = 2.12\n\n// ignore_for_file: annotate_overrides, camel_case_types, comment_references\n// ignore_for_file: constant_identifier_names, library_prefixes\n// ignore_for_file: non_constant_identifier_names, prefer_final_fields\n// ignore_for_file: unnecessary_import, unnecessary_this, unused_import\n\nimport \'dart:convert\' as $convert;\nimport \'dart:core\' as $core;\nimport \'dart:typed_data\' as $typed_data;\n\n@$core.Deprecated(\'Use emptyDescriptor instead\')\nconst Empty$json = {\n \'1\': \'Empty\',\n};\n\n/// Descriptor for `Empty`. Decode as a `google.protobuf.DescriptorProto`.\nfinal $typed_data.Uint8List emptyDescriptor = $convert.base64Decode(\n \'CgVFbXB0eQ==\');\n\n\n ```

Does someone see something off?

puellanivis commented 5 months ago

That the plugin output starts with \020 is kind of suspect, as that is the space character.

We’ve seen similar issues with extra output being injected into one or the other protoc or our protoc-gen-go.

That there might be some sort of extra output is about the only help or hint that we can really provide here. I don’t know enough about the protoc-gen-dart code to say anything about what output it should be generating.

jonasbadstuebner commented 5 months ago

Thank you so much for the hint! It was not the space, but your hint sparked a new idea and it turned out to be very likely related to a wrapper tool I am using. It adds an additional newline at the end of the dart plugin output.

I'm closing this, thank you very much again!