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

Error "The named parameter 'valueDefaultOrMaker' isn't defined." in version 21.1.2 (protoc 26.1) #925

Closed
philer-jambit opened this issue Mar 28, 2024 · 3 comments

Comments

@philer-jambit
Copy link

philer-jambit commented Mar 28, 2024

When I compile the following protobuf I get invalid dart code:

syntax = "proto3";

package example;

message Inner {
  string bar = 1;
}

message Outer {
  map<string, Inner> entries = 1;
}

The generated code contains this block:

class Outer extends $pb.GeneratedMessage {
  // ...

  static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'Outer', package: const $pb.PackageName(_omitMessageNames ? '' : 'example'), createEmptyInstance: create)
    ..m<$core.String, Inner>(1, _omitFieldNames ? '' : 'entries', entryClassName: 'Outer.EntriesEntry', keyFieldType: $pb.PbFieldType.OS, valueFieldType: $pb.PbFieldType.OM, valueCreator: Inner.create, valueDefaultOrMaker: Inner.getDefault, packageName: const $pb.PackageName('example'))
    ..hasRequiredFields = false
  ;

Full file: example.pb.dart.txt

The argument valueDefaultOrMaker is noted as an error by dart: The named parameter 'valueDefaultOrMaker' isn't defined.

This was previously reported in #786. At the time it was noted that the user was probably on a not yet released version – however the bug (presumably?) has since been released.

Please let me know if there is anything else I should try or do to help.


dart protoc_plugin installed via dart pub global activate protoc_plugin: 21.1.2
protoc downloaded from https://github.com/protocolbuffers/protobuf/releases/tag/v26.1

@osa1
Copy link
Member

osa1 commented Mar 30, 2024

Make sure you are using the latest version of protobuf (3.1.0), and run dart pub get. The named parameter is defined https://pub.dev/documentation/protobuf/latest/protobuf/BuilderInfo/m.html (search for valueDefaultOrMaker) so you probably have a problem with your setup.

@philer-jambit
Copy link
Author

It turns out we are still on v2 (I was a bit confused about the distinct versions for the protobuf compiler and support library) due to a dependency. So now we are stuck here: PhilipsHue/flutter_reactive_ble#785

Since that is outside of your domain I guess this issue can be closed. Thank you for your support! :)

@philer-jambit
Copy link
Author

In case anyone else gets stuck in the same place: As a workaround we're currently just removing the offending parameter.

find -name "*.pb.dart" | xargs sed -i 's/valueDefaultOrMaker: [[:alnum:]]\+\.getDefault,//g'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants