Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

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

Open
sorgfal opened this issue Jun 21, 2020 · 14 comments
Open

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

sorgfal opened this issue Jun 21, 2020 · 14 comments

Comments

@sorgfal
Copy link

sorgfal commented Jun 21, 2020

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

@boeledi
Copy link

boeledi commented Jul 6, 2020

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.

@itsnuba
Copy link

itsnuba commented Aug 6, 2020

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

@akasher
Copy link

akasher commented Aug 11, 2020

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


I am facing the same issue

@knoja4
Copy link

knoja4 commented Aug 11, 2020

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.

@brandan-schmitz
Copy link

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.

@zLdR89
Copy link

zLdR89 commented Sep 11, 2020

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

@disburden
Copy link

same issue, waiting for a solution

@aspantel
Copy link

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


@Aldo111
Copy link

Aldo111 commented Oct 1, 2020

Any updates on this?

@disburden
Copy link

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

@boeledi
Copy link

boeledi commented Oct 1, 2020

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?

@Reductions
Copy link
Contributor

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

@Aldo111
Copy link

Aldo111 commented Oct 2, 2020

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?

@fodil-a
Copy link

fodil-a commented Nov 25, 2020

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

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

No branches or pull requests