google / googleapis.dart

Repository for building the googleapis packages
https://pub.dev/packages/googleapis
BSD 3-Clause "New" or "Revised" License
394 stars 119 forks source link

Bigquery API fails: type 'Null' is not a subtype of type 'Object' in type cast #306

Closed keyonghan closed 3 years ago

keyonghan commented 3 years ago

We (flutter/cocoon) recently migrated our backend to null safety, and started hitting below error (with googleapis version 3.0.0). I guess the culprit is: https://github.com/google/googleapis.dart/blob/master/generated/googleapis/lib/bigquery/v2.dart#L11097 where v: _json.containsKey('v') ? _json['v'] as core.Object : null should be updated to v: _json.containsKey('v') ? _json['v'] as core.Object? : null to consider the value null case.

type 'Null' is not a subtype of type 'Object' in type cast
#0      new TableCell.fromJson (package:googleapis/bigquery/v2.dart:11018:50)
#1      new TableRow.fromJson.<anonymous closure> (package:googleapis/bigquery/v2.dart:11704:56)
#2      MappedListIterable.elementAt (dart:_internal/iterable.dart:413:31)
#3      ListIterator.moveNext (dart:_internal/iterable.dart:342:26)
#4      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:188:27)
#5      new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#6      new List.of (dart:core-patch/array_patch.dart:51:28)
#7      ListIterable.toList (dart:_internal/iterable.dart:213:44)
#8      new TableRow.fromJson (package:googleapis/bigquery/v2.dart:11706:20)
#9      new QueryResponse.fromJson.<anonymous closure> (package:googleapis/bigquery/v2.dart:9588:54)
#10     MappedListIterable.elementAt (dart:_internal/iterable.dart:413:31)
#11     ListIterator.moveNext (dart:_internal/iterable.dart:342:26)
#12     new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:188:27)
#13     new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#14     new List.of (dart:core-patch/array_patch.dart:51:28)
#15     ListIterable.toList (dart:_internal/iterable.dart:213:44)
#16     new QueryResponse.fromJson (package:googleapis/bigquery/v2.dart:9590:20)
#17     JobsResource.query (package:googleapis/bigquery/v2.dart:796:26)
<asynchronous suspension>
#18     BigqueryService.listBuilderStatistic (package:cocoon_service/src/service/bigquery.dart:86:36)
<asynchronous suspension>
#19     FileFlakyIssueAndPR.get (package:cocoon_service/src/request_handlers/file_flaky_issue_and_pr.dart:39:57)

Related: https://github.com/flutter/flutter/issues/90019

keyonghan commented 3 years ago

/cc @kevmoo I see you have been working on this repo, could you please take a look? This is blocking us running some cronjobs for prod development workflow. Please help reassign as you see fit. Thanks!

kevmoo commented 3 years ago

Fix published in https://pub.dev/packages/googleapis/versions/6.0.0