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

Scroll api 5.0, 5.1, 5.2 throwing error against elastic search 5.3+ #573

Closed
kjg opened this issue Jul 25, 2017 · 9 comments
Closed

Scroll api 5.0, 5.1, 5.2 throwing error against elastic search 5.3+ #573

kjg opened this issue Jul 25, 2017 · 9 comments

Comments

@kjg
Copy link
Contributor

kjg commented Jul 25, 2017

When I use the 5.0, 5.1, 5.2 scroll API from elasticsearch-js 13.1.1 or 13.2.0 against elasticsearch versions 5.3 and up I get the error

Error: [illegal_argument_exception] Failed to parse request body

In this case the request body is just a plain string which is the scroll id, not a json payload of form {scrollId: scrollId}

Does elasticsearch 5.3 not allow for requests via API 5.0, 5.1, 5.2, or do those API definitions need to be updated, or any idea what I might be doing wrong here?

@kjg
Copy link
Contributor Author

kjg commented Jul 25, 2017

Wait, is the apiVersion we set in the client supposed to always match the version of elasticsearch you're connecting to? If so, does upgrading elasticsearch always require a version bump in the config of the client code and downtime of the app?

@kjg
Copy link
Contributor Author

kjg commented Jul 25, 2017

As far as I can tell, the string only body was last in the docs on version 1.7, all newer versions show using the json body.

Maybe all the api specs need to be updated then? Do we need to update

  • api.scroll = ca({
    params: {
    scroll: {
    type: 'time'
    },
    scrollId: {
    type: 'string',
    name: 'scroll_id'
    }
    },
    urls: [
    {
    fmt: '/_search/scroll/<%=scrollId%>',
    req: {
    scrollId: {
    type: 'string'
    }
    }
    },
    {
    fmt: '/_search/scroll'
    }
    ],
    paramAsBody: 'scrollId',
    method: 'POST'
    });
  • api.scroll = ca({
    params: {
    scroll: {
    type: 'time'
    },
    scrollId: {
    type: 'string',
    name: 'scroll_id'
    }
    },
    urls: [
    {
    fmt: '/_search/scroll/<%=scrollId%>',
    req: {
    scrollId: {
    type: 'string'
    }
    }
    },
    {
    fmt: '/_search/scroll'
    }
    ],
    paramAsBody: 'scrollId',
    method: 'POST'
    });
  • api.scroll = ca({
    params: {
    scroll: {
    type: 'time'
    },
    scrollId: {
    type: 'string',
    name: 'scroll_id'
    }
    },
    urls: [
    {
    fmt: '/_search/scroll/<%=scrollId%>',
    req: {
    scrollId: {
    type: 'string'
    }
    }
    },
    {
    fmt: '/_search/scroll'
    }
    ],
    paramAsBody: 'scrollId',
    method: 'POST'
    });

to match

api.scroll = ca({
params: {
scroll: {
type: 'time'
},
scrollId: {
type: 'string',
name: 'scroll_id'
}
},
urls: [
{
fmt: '/_search/scroll/<%=scrollId%>',
req: {
scrollId: {
type: 'string'
}
}
},
{
fmt: '/_search/scroll'
}
],
paramAsBody: {
param: 'scrollId',
body: 'scroll_id'
},
method: 'POST'
});

@kjg
Copy link
Contributor Author

kjg commented Jul 27, 2017

After much digging, I think this is the change that needs to be made (followed by a npm run generate)

diff --git i/scripts/generate/overrides.js w/scripts/generate/overrides.js
index fd8aa9c..2607852 100644
--- i/scripts/generate/overrides.js
+++ w/scripts/generate/overrides.js
@@ -252,7 +252,7 @@ function (spec) {
     }
   },
   {
-    version: '>=5.3',
+    version: '>=2.0',
     paramAsBody: {
       scroll: {
         param: 'scrollId',

What do you think @spalger? Do you happen to remember why you had it as 5.3+ before

@spalger
Copy link
Contributor

spalger commented Jul 28, 2017

I did that as 5.3+ because elastic/elasticsearch#22691 went into 5.3, but that's unfortunate that this doesn't work in 5.0+... I really need to get the functional tests for the client up and running again

@spalger
Copy link
Contributor

spalger commented Jul 28, 2017

Are you sure that should be >=2.0? Wouldn't >=5.0 be more appropriate?

@kjg
Copy link
Contributor Author

kjg commented Jul 28, 2017

@spalger I went with >=2.0 because the 1.7 docs show the body as just the requestId value

curl -XGET  'localhost:9200/_search/scroll?scroll=1m'   \
     -d       'c2Nhbjs2OzM0NDg1ODpzRlBLc0FXNlNyNm5JWUc1' 

and the 2.0 and up docs all support the json version

curl -XGET  'localhost:9200/_search/scroll'  -d'
{
    "scroll" : "1m", 
    "scroll_id" : "c2Nhbjs2OzM0NDg1ODpzRlBLc0FXNlNyNm5JWUc1" 
}
'

screen shot 2017-07-28 at 12 28 36 pm

And the note about for backwards compatibly scroll_id can be passed in the request body was removed in the 5.0 docs

My opinion is 2.0 -> 2.4 should use the json body version instead of the backwards compatible version since they support both styles, but you are obviously much closer to the project, so I'll defer to your expertise.

Would you like me to make the PR for this change? If so should I use >=2.0 or >=5.0 after the above consideration? And also, should I include the new output of npm run generate in the PR or does that always get updated after merge into master?

Thanks so much for taking a look at this!

@spalger
Copy link
Contributor

spalger commented Jul 28, 2017

Nice, sounds like a valid reason to me! A PR would be very helpful, and >=2.0 sounds great

@kjg
Copy link
Contributor Author

kjg commented Jul 28, 2017

Should I include the output of npm run generate in the PR or does that always get updated after merge into master?

@spalger
Copy link
Contributor

spalger commented Jul 31, 2017

@kjg I actually run it manually but like to keep it separate from the PRs. Thanks again!

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

No branches or pull requests

2 participants