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

Type 'List<String>' is not a subtype of type 'String' in AlgoliaMultiIndexesReference #115

Open
SebastianWaloszek opened this issue Mar 23, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@SebastianWaloszek
Copy link

Dart version: 2.18.6
Flutter version: 3.3.10 (stable)

Describe the bug
When one sets a list of facet filters for a query to be performed as part of getObjects() inside AlgoliaMultiIndexesReference there's an encoding error being thrown.

dart:core                                        new _Uri
package:algolia/src/index_reference.dart 358:23  AlgoliaMultiIndexesReference._encodeMap
package:algolia/src/index_reference.dart 391:19  AlgoliaMultiIndexesReference.getObjects
test/algolia_test.dart 158:43                    main.<fn>.<fn>

type 'List<String>' is not a subtype of type 'String'

It only happens for AlgoliaMultiIndexesReference. When we try doing the same for AlgoliaIndexReference it works without issues.

To Reproduce
One can reproduce the issue in tests by adding a list of facet filters:

      queryA = queryA.facetFilter([
        'email:johan.1@example.com',
        'email:johan.2@example.com',
      ]);

in the Perform Multiple Queries test like this:

    test('Perform Multiple Queries', () async {
      var queryA = algolia.instance.index('contacts').query('john');
      var queryB = algolia.instance.index('contacts_alt').query('jo');

      // Perform multiple facetFilters
      queryA = queryA.facetFilter('status:published');
      queryA = queryA.facetFilter('isDelete:false');
      queryA = queryA.facetFilter([
        'email:johan.1@example.com',
        'email:johan.2@example.com',
      ]);

      try {
        // Get Result/Objects
        var snap = await algolia.multipleQueries
            .addQueries([queryA, queryB]).getObjects();
        // Checking if has [List<AlgoliaQuerySnapshot>]
        expect(snap.length, 2);
        print('Queries count: ${snap.length}');
      } on AlgoliaError catch (err) {
        print(err.error.toString());
        expect(err.runtimeType, AlgoliaError);
      }
      print('\n\n');
    });

Expected behavior
Encoding error should not happen inside AlgoliaMultiIndexesReference when the set facet filter for a query is a List<String>.

@SebastianWaloszek
Copy link
Author

I have proposed a solution to this issue in this PR: #116

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant