Skip to content

Conversation

@KDwevedi
Copy link
Contributor

@KDwevedi KDwevedi commented Nov 6, 2024

Description

The query returned by the query builder returns the following error:

The [query] field is invalid. Explanation [No explanation available].

Changes

For this query generator:

queryUsersByApplicationIdAndQueryString(applicationId: string[], queryString: string): string{
        const query = {
            bool: {
              must: [
                {
                  bool: {
                    must: [
                      [
                        {
                          nested: {
                            path: "registrations",
                            query: {
                              bool: {
                                should: this.createMatchTags(applicationId)
                              }
                            }
                          }
                        }
                      ]
                    ]
                  }
                },
                {
                  query_string: {
                    query: queryString
                  }
                }
              ]
            }
          }
          return JSON.stringify(query)
    }  

The innermost must clause is now Array instead of being Array<Array>:

queryUsersByApplicationIdAndQueryString(applicationId: string[], queryString: string): string{
        const query = {
            bool: {
              must: [
                {
                  bool: {
                    must: [
                        {
                          nested: {
                            path: "registrations",
                            query: {
                              bool: {
                                should: this.createMatchTags(applicationId)
                              }
                            }
                          }
                        }
                    ]
                  }
                },
                {
                  query_string: {
                    query: queryString
                  }
                }
              ]
            }
          }
          return JSON.stringify(query)
    }

How to test

  • updated src/api/fusionauth/query-generator/query-generator.service.spec.ts to run the relevant test
  • The following curl should return success, responseCode: "OK"
curl --location 'http://localhost:3000/api/searchUserByQuery?queryString=username%3AvalidUsername&startRow=0&numberOfResults=1' \
--header 'x-application-id: ***' \
--header 'Authorization: ***'

@github-actions
Copy link

github-actions bot commented Nov 6, 2024

Pull Request Test Coverage Report for Build 11701173151

Details

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 23.52%

Totals Coverage Status
Change from base Build 10590606815: 0.0%
Covered Lines: 624
Relevant Lines: 2381

💛 - Coveralls

@KDwevedi KDwevedi merged commit 74b9850 into master Nov 6, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants