-
Notifications
You must be signed in to change notification settings - Fork 21
fix: prevents runtime error on undefined facets
#48
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
Open
gerardosabetta
wants to merge
1
commit into
elastic:master
Choose a base branch
from
gerardosabetta:patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: prevents runtime error on undefined
facets
It is not safe to assume that facets is going to be in the response
- Loading branch information
commit 42f8b51ee1fca0ca8cc4d851eb72895a1643a009
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
fixtures/host-2376rb.api.swiftype.com-443/disjunctive_license_returning_no_facets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| POST /api/as/v1/engines/node-modules/search.json | ||
| authorization: Bearer api-hean6g8dmxnm2shqqiag757a | ||
| content-type: application/json | ||
| x-swiftype-client: elastic-app-search-javascript | ||
| x-swiftype-client-version: 8.7.0 | ||
| accept: */* | ||
| accept-encoding: gzip,deflate | ||
| body: {\"query\":\"dog\",\"page\":{\"size\":0},\"filters\":{},\"facets\":{\"license\":[{\"type\":\"value\",\"size\":3}]},\"record_analytics\":false,\"analytics\":{\"tags\":[\"Facet-Only\"]}} | ||
|
|
||
| HTTP/1.1 200 OK | ||
| date: Thu, 27 Sep 2018 20:36:08 GMT | ||
| content-type: application/json; charset=utf-8 | ||
| transfer-encoding: chunked | ||
| connection: close | ||
| vary: Accept-Encoding, Origin | ||
| status: 200 OK | ||
| x-frame-options: SAMEORIGIN | ||
| x-xss-protection: 1; mode=block | ||
| x-content-type-options: nosniff | ||
| etag: W/"d31aa222a68122cb8392577cf4a1a7f1" | ||
| cache-control: max-age=0, private, must-revalidate | ||
| x-request-id: 91197d45d104a3e2281a60eecec630ff | ||
| x-runtime: 0.270027 | ||
| x-swiftype-frontend-datacenter: dal05 | ||
| x-swiftype-frontend-node: web01.dal05 | ||
| x-swiftype-edge-datacenter: dal05 | ||
| x-swiftype-edge-node: web01.dal05 | ||
|
|
||
| {"meta":{"warnings":[],"page":{"current":1,"total_pages":0,"total_results":0,"size":1},"request_id":"91197d45d104a3e2281a60eecec630ff"},"results":[]} |
29 changes: 29 additions & 0 deletions
29
...rb.api.swiftype.com-443/search_filter_and_multi_facet_with_disjuntive_returning_no_facets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| POST /api/as/v1/engines/node-modules/search.json | ||
| authorization: Bearer api-hean6g8dmxnm2shqqiag757a | ||
| content-type: application/json | ||
| x-swiftype-client: elastic-app-search-javascript | ||
| x-swiftype-client-version: 8.7.0 | ||
| accept: */* | ||
| accept-encoding: gzip,deflate | ||
| body: {\"query\":\"dog\",\"page\":{\"size\":1},\"filters\":{\"license\":\"BSD\"},\"facets\":{\"license\":[{\"type\":\"value\",\"size\":3}],\"dependencies\":[{\"type\":\"value\",\"size\":3}]}} | ||
|
|
||
| HTTP/1.1 200 OK | ||
| date: Thu, 27 Sep 2018 20:53:56 GMT | ||
| content-type: application/json; charset=utf-8 | ||
| transfer-encoding: chunked | ||
| connection: close | ||
| vary: Accept-Encoding, Origin | ||
| status: 200 OK | ||
| x-frame-options: SAMEORIGIN | ||
| x-xss-protection: 1; mode=block | ||
| x-content-type-options: nosniff | ||
| etag: W/"5010d52221547ddec5baceeb9f8a4931" | ||
| cache-control: max-age=0, private, must-revalidate | ||
| x-request-id: 8369bdda4d5c018ddbd85fc2859fbadb | ||
| x-runtime: 0.212519 | ||
| x-swiftype-frontend-datacenter: dal05 | ||
| x-swiftype-frontend-node: web01.dal05 | ||
| x-swiftype-edge-datacenter: dal05 | ||
| x-swiftype-edge-node: web01.dal05 | ||
|
|
||
| {"meta":{"warnings":[],"page":{"current":1,"total_pages":0,"total_results":0,"size":10},"request_id":"8369bdda4d5c018ddbd85fc2859fbadb"},"results":[]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good but the testcase is incorrect. What you want in the testcase is to validate that the request doesn't have the presence of facets object. I still see in the request fixture, the facets object thats populated with a facet configuration (which is expected with this testcase).
I think you should see this behavior (without the fix) with the following configuration:
The other way is to filter disjunctiveFacets array that are only present in facets objects too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's correct; I don't want to validate the request not having the presence of the facet object. It's the response what I really care about. That's why I do the assertion down below. This is really similar to the original request that produced the issue for me if you look back to the original slack thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior doesn't reproduce by modifying the request as you suggested. It produces a different error:
Because

Facet-Onlyrequest goes out to fetch the disjunctive "license" tagThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joemcelroy any updates?