Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cloud_firestore] error-Invalid argument (dartObject): Could not convert: Instance of 'Timestamp' #2153

Closed
kushvatsa opened this issue Mar 10, 2020 · 11 comments · Fixed by #2166
Assignees
Labels
type: bug Something isn't working

Comments

@kushvatsa
Copy link
Contributor

kushvatsa commented Mar 10, 2020

Hey @ditman , While doing pagination on flutter web, cloud firestore gives error error-Invalid argument (dartObject): Could not convert: Instance of 'Timestamp'

try {
      Firestore fireStore = Firestore.instance;
      final QuerySnapshot docs = await fireStore
          .collectionGroup("vote")
          .where("uid", isEqualTo: uid)
          .orderBy(fieldVal, descending: true)
          .startAfterDocument(doc)
          .limit(2)
          .getDocuments();
 } catch (e) {
      print("error-" + e.toString());
      return null;
    }
@iapicca
Copy link

iapicca commented Mar 11, 2020

Hi @kushvatsa
can you please provide your flutter doctor -v ,
your flutter run --verbose
and your pubspec.yaml
or if possible a reproducible minimal code sample.
Thank you

@iapicca iapicca added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Mar 11, 2020
@ditman
Copy link
Contributor

ditman commented Mar 11, 2020

@kushvatsa can you also describe a little bit the data structures you're using? Is the Timestamp failing in the startAfterDocument line, or elsewhere?

Is this because your doc contains a Timestamp type?

@kushvatsa
Copy link
Contributor Author

  final String fieldVal = 'created_time';
  DocumentSnapshot doc;

initData() async {
    try {
      final docs = await Firestore.instance
          .collectionGroup("vote")
          .where("uid", isEqualTo: uid)
          .orderBy(fieldVal, descending: true)
          .limit(2)
          .getDocuments();
      doc = docs.documents.first;
    } catch (e) {
      print("error-" + e.toString());
      return null;
    }
  }

  nextData() async {
    try {
      Firestore fireStore = Firestore.instance;
      await fireStore
          .collectionGroup("vote")
          .where("uid", isEqualTo: uid)
          .orderBy(fieldVal, descending: true)
          .startAfterDocument(doc)
          .limit(2)
          .getDocuments();
    } catch (e) {
      print("error-" + e.toString());
      return null;
    }
  }

@ditman , yes. TimeStamp failing in the startAfterDocument and also in the endBeforeDocument.

@kushvatsa
Copy link
Contributor Author

@iapicca , check the above comment. Thanks!

@iapicca
Copy link

iapicca commented Mar 12, 2020

Hi @kushvatsa
could you please provide these info
thank you

@ditman
Copy link
Contributor

ditman commented Mar 12, 2020

@iapicca no need, this comes from a past issue where I asked @kushvatsa to start a new one. This issue can be reproduced by the tests of the _web plugin. I'll get on this ASAP. Thanks!

@ditman ditman self-assigned this Mar 12, 2020
@iapicca
Copy link

iapicca commented Mar 12, 2020

Thank for the clarification @ditman

@iapicca iapicca removed the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Mar 12, 2020
@ditman
Copy link
Contributor

ditman commented Mar 13, 2020

The current tests can reproduce this issue:

00:07 +7: Firestore pagination [E]
Invalid argument (dartObject): Could not convert: Instance of 'Timestamp'
package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 196:49      throw_
  package:firebase/src/utils.dart 119:3                                                     jsify
  package:dart-sdk/lib/internal/iterable.dart 417:29                                        elementAt
  package:dart-sdk/lib/internal/iterable.dart 221:19                                        toList
  package:firebase/src/firestore.dart 552:22
  [_wrapPaginatingFunctionCall]
  package:firebase/src/firestore.dart 523:11                                                startAt
  package:cloud_firestore_web/src/query_web.dart 180:17                                     startAtDocument
  package:cloud_firestore/src/query.dart 130:17                                             startAtDocument
  package:firestore_example/main.dart 193:48                                                <fn>

The error happens here.

Investigating.

ditman added a commit to ditman/firebase-flutterfire that referenced this issue Mar 13, 2020
This change ensures that the package:firestore Query objects are created
with properly encoded values when done so from the start/end
(pagination) methods.

This also adds some Timestamps to the unit tests to verify the behavior of
Timestamp -> DateTime.

There are some integration tests in cloud_firestore that cover this
behavior further.

Fixes firebase#2153
ditman added a commit that referenced this issue Mar 19, 2020
…2166)

This change ensures that the package:firestore Query objects are created with properly encoded values when done so from the start/end (pagination) methods.

This also adds some Timestamps to the unit tests to verify the behavior of Timestamp -> DateTime in the web implementation.

(There are some integration tests in cloud_firestore that cover this behavior further.)

Fixes #2153

* [cloud_firestore_platform_interface] Fix 'equal_keys_in_map' lint (unrelated fix, but this change triggered an analysis in a sibling package)
@ditman
Copy link
Contributor

ditman commented Mar 20, 2020

Tagged and published cloud_firestore_web 0.1.1+2 with a fix for this issue. Please update your dependencies and let me know how it goes!

@kushvatsa
Copy link
Contributor Author

It works @ditman , Thank you very much. 👍

@ditman
Copy link
Contributor

ditman commented Mar 20, 2020

Awesome, thanks for your patience!

@firebase firebase locked and limited conversation to collaborators Aug 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants