stablekernel/aqueduct

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

Opened this issue · 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 {}
}

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.

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

-- 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

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.

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.

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

same issue, waiting for a solution

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)

Any updates on this?

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

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?

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

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?

This should be fixed with this PR

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