aqueduct icon indicating copy to clipboard operation
aqueduct copied to clipboard

db generate. The getter 'length' was called on null.

Open sorgfal opened this issue 4 years ago • 14 comments

Hi this error happens when i try to execute db generate, with existed migration file. If i delete first migration, new migration will be generated normally.

MacBook-Pro-MacBook:pinta_server pro$ aqueduct db generate -- Aqueduct CLI Version: 4.0.0-b1 -- Aqueduct project version: 4.0.0-b1 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>:15:813) #3 SchemaBuilderExecutable.execute (<data:application/dart>:14:873) #4 main (<data:application/dart>:10:35) #5 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:32) #6 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

Now my migrations folder look like migrations/ 00000001_initial.migration.dart

00000001_initial.migration.dart class Migration1 extends Migration { @override Future upgrade() async { database.createTable(SchemaTable("stores", [SchemaColumn("id", ManagedPropertyType.integer, isPrimaryKey: true, autoincrement: true, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("title", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false)])); }

@override Future downgrade() async {}

@override Future seed() async {} }

sorgfal avatar Jun 21 '20 10:06 sorgfal

Hi, I also have this error when working with Flutter Channel Beta. As a temporary solution, switch to the Flutter Channel Stable. This allows me to use the CLI.

boeledi avatar Jul 06 '20 11:07 boeledi

im also experiencing the same error for validating migration file using aqueduct db validate Anybody have a workaround? i cannot reset the migration because its used on production db

itsnuba avatar Aug 06 '20 07:08 itsnuba

-- Aqueduct CLI Version: 4.0.0-b1 -- Aqueduct project version: 4.0.0-b1 Replaying versions: 14... *** 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:15:813)
  • #3 SchemaBuilderExecutable.execute (data:application/dart:14:873)
  • #4 main (data:application/dart:10:35)
  • #5 _startIsolate. (dart:isolate-patch/isolate_patch.dart:297:32)
  • #6 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

I am facing the same issue

akasher avatar Aug 11 '20 11:08 akasher

Hi, I also have this error when working with Flutter Channel Beta. As a temporary solution, switch to the Flutter Channel Stable. This allows me to use the CLI.

I'm on stable channel, and I'm experiencing the same issue/error message as @sorgfal with aqueduct db generate if any migration files already exist, and the same goes for aqueduct db validate, as indicated by @itsnuba .

So even though an initial migration file was created just fine after deleting existing ones, and aqueduct db upgrade... modified my API's existing postgresql db without error, this "getter 'length' was called on null" error still happens when aqueduct db validate is run, and the bottom line is my Flutter client cannot connect to aqueduct. No API calls from Flutter show up in aqueduct's console log.

knoja4 avatar Aug 11 '20 11:08 knoja4

I have had a similar issue. I found that making sure I was on Dart 2.8.3 solved my issue. Newer versions of dart seemed to break this.

brandan-schmitz avatar Aug 15 '20 08:08 brandan-schmitz

does anybody know when this problem will be solved with current dart sdk?

zLdR89 avatar Sep 11 '20 10:09 zLdR89

same issue, waiting for a solution

disburden avatar Sep 20 '20 17:09 disburden

same issue ...

-- Aqueduct CLI Version: 4.0.0-b1 -- Aqueduct project version: 4.0.0-b1 Replaying versions: 1, 2... *** 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:15:813)
  • #3 SchemaBuilderExecutable.execute (data:application/dart:14:873)
  • #4 main (data:application/dart:10:35)
  • #5 _startIsolate. (dart:isolate-patch/isolate_patch.dart:297:32)
  • #6 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

aspantel avatar Sep 21 '20 16:09 aspantel

Any updates on this?

Aldo111 avatar Oct 01 '20 05:10 Aldo111

The only way to solve this problem is downgrade dart to 2.8.x

disburden avatar Oct 01 '20 05:10 disburden

This is not an acceptable solution as I am also developing in Flutter for the Mobile-side and because of this issue, each time that I need to run the CLI, I need to downgrade the Dart SDK.... not very convenient. It really becomes difficult. Does anyone have an idea how to debug the CLI?

boeledi avatar Oct 01 '20 07:10 boeledi

If you want multiple versions of dart I would recommend using asdf.

As for solution without downgrading you could override the aqueduct dependency:

dependency_overrides:
  aqueduct:
    git:
      url: https://github.com/stablekernel/aqueduct
      path: aqueduct
      ref: 0af9712a95205c1b73bdc12ebd3a6db8b141233b

Reductions avatar Oct 01 '20 08:10 Reductions

Will try that out, thanks @Reductions! Just curious, what was the core issue/why was the latest version of Dart incompatible? Was it somehow an issue with Isolates or the way the non-initial migrations were validated/generated?

Aldo111 avatar Oct 02 '20 07:10 Aldo111

This should be fixed with this PR

To explain the issue, the dart team changed how ClassMirror uses namedArguments, but Executable<T> always passed null so it never worked with Dart >2.8

fodil-a avatar Nov 25 '20 20:11 fodil-a