stablekernel / aqueduct

Dart HTTP server framework for building REST APIs. Includes PostgreSQL ORM and OAuth2 provider.
https://aqueduct.io
BSD 2-Clause "Simplified" License
2.42k stars 280 forks source link

Bad state: NoSuchMethodError: The getter 'length' was called on null. #931

Open vinnytwice opened 3 years ago

vinnytwice commented 3 years ago

I'm having this error when running aqueduct db generate command but only if an initial migration file exists. In order to make changes to my db I have to delete it and then I can generate one.. What should I check out to troubleshoot it? Many thanks. This is the print from console :

vinnytwice@Vinnys-iMac fixit_server % aqueduct db generate
-- Aqueduct CLI Version: 3.3.0+1
-- Aqueduct project version: 3.3.0+1
    Replaying versions: 1...
*** Uncaught error
    Bad state: NoSuchMethodError: The getter 'length' was called on null.
Receiver: null
Tried calling: length
  **** Stacktrace
  * #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
  * #1      _ClassMirror.newInstance (dart:mirrors-patch/mirrors_impl.dart:653:44)
  * #2      Executable.instanceOf (<data:application/dart>:14:813)
  * #3      SchemaBuilderExecutable.execute (<data:application/dart>:13:873)
  * #4      main (<data:application/dart>:9:35)
  * #5      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:32)
  * #6      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
  ****
vinnytwice commented 3 years ago

I tried Dart 2.8 and it worked just partially and only with dependency_overrides: Postgres: 2.2.0 set in pubspec.yamlfile . Now, aqueduct db generatecommand works with this version but I'd still get the RangeError when running aqueduct db upgrade command.. so still pretty useless.. I then tried 2.9 but it seems that this version doesn't allow CLI.. #903 So I finally tried 2.7 and both commands now work properly and without dependency_overrides: Postgres: 2.2.0. What would be the correct Dart/Aqueduct/PostgreSQL setup to work with higher Dart versions like the latest stable 2.10 ? Thank you very much.

ayazemre commented 3 years ago

We need to wait for next release which should arrive soon. In Slack they mentioned about releasing it Q12021 if my memory is not wrong. Try to run it with pub run, it solved my problem temporarily.

vinnytwice commented 3 years ago

@ayazthemre that would be a version 4? Apparently to make it work with Dart 2.8 this pubspec.yaml file setup would work.

ubspec.yaml file:

name: mysecurename description: mysecuredescription version: 0.1.0 environment: sdk: ">=2.7.0 <3.0.0" dependencies: aqueduct: ^4.0.0-b1 analyzer: '>=0.32.0 <0.41.0' runtime: ^1.0.0-5 http: ^0.12.0+4 mime: ^0.9.6+3 dev_dependencies: test: ^1.0.0 aqueduct_test: ^2.0.0-b1

Havent tested it yet dough.. What benefits does have aqueduct 4 over 3 ?

ayazemre commented 3 years ago

@ayazthemre that would be a version 4? Apparently to make it work with Dart 2.8 this pubspec.yaml file setup would work.

ubspec.yaml file:

name: mysecurename description: mysecuredescription version: 0.1.0 environment: sdk: ">=2.7.0 <3.0.0" dependencies: aqueduct: ^4.0.0-b1 analyzer: '>=0.32.0 <0.41.0' runtime: ^1.0.0-5 http: ^0.12.0+4 mime: ^0.9.6+3 dev_dependencies: test: ^1.0.0 aqueduct_test: ^2.0.0-b1

Havent tested it yet dough.. What benefits does have aqueduct 4 over 3 ?

I don't know the benefits but since it will be latest stable version after breaking dart updates we should not be having any problems out of the box. Current as you can see there is -b after version number which I guess means beta. Even in v4 some people seem to have problems so do not use it for production release.

vinnytwice commented 3 years ago

Got it. I'll stay on current setup then untill a stable issue-free version 4 gets published. Cheers