You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"environment" is removed from header in getService() in version 1.8.x #47
We upgraded from 1.4 to 1.8 recently, and noticed an issue in recent 1.8.x versions that the following fetches after first one fails because of error: "error_message":"Failed to fetch entries. Please try again with valid parameters.","error_code":141,"errors":{"environment":["is required."]}}
changed the title [-]"environment" is removed from header in getService() in version 1.8.1[/-][+]"environment" is removed from header in getService() in version 1.8.x[/+]on Feb 11, 2022
Hi, @zxm5010 thanks for writing us. We have removed the environment from the header. As per the documentation environment should go with Query Parameters see the documentation.
Thanks @ishaileshmishra . We will add environment as a query param. So the environment passed into Stack constructor is no longer needed or used internally?
Second question:
we recently also notice after upgrading to version 1.8.x, stack object randomly returns {"error_message":"We can't find that Stack. Please try again.","error_code":109,"errors":{"api_key":["is not valid."]}} We have to reinitialize stack object again when encountering this. Any idea what change may cause it? It didn't happen in 1.4 for our live environment.
1 - Quick clarification, we are always getting "error_message":"Failed to fetch entries. Please try again with valid parameters.","error_code":141,"errors":{"environment":["is required."]}} after the first fetch request, unless if we set header explicitly. I think there's something overwrites stack's context/header internally when we do fetches. Maybe it also relates to api_key error
For more context, we are fetching nested contents. And, nested fetches are called in the onCompletion method.
Example:
stack.contentType("root_content").query().find(
new QueryResultsCallback() {
public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error) {
if (error == null) {
//Success block
List<Entry> results = queryResult.getResultObjects();
for (Entry entry : results) {
JSONArray childrenContentRefs = entry.getJSONArray("children_content_refs");
for(int i = 0; i < childrenContentRefs.length(); i++) {
String uid = childrenContentRefs.getJSONObject(i).getString("uid");
Entry entry = stack.contentType("children_content").entry(uid);
// ... logic dealing with children entry are truncated.
}
}
} else {
//Error block
}
}
}
)
Not sure if there's any behavior changes internally how the requests getting handled, but the logic mentioned above behaves fine in version 1.4.x, but start to behave unstable in 1.8.x
Activity
[-]"environment" is removed from header in getService() in version 1.8.1[/-][+]"environment" is removed from header in getService() in version 1.8.x[/+]ishaileshmishra commentedon Feb 14, 2022
Hi, @zxm5010 thanks for writing us. We have removed the environment from the header. As per the documentation environment should go with Query Parameters see the documentation.
zxm5010 commentedon Feb 14, 2022
Thanks @ishaileshmishra . We will add environment as a query param. So the environment passed into Stack constructor is no longer needed or used internally?
Second question:
we recently also notice after upgrading to version 1.8.x, stack object randomly returns
{"error_message":"We can't find that Stack. Please try again.","error_code":109,"errors":{"api_key":["is not valid."]}}We have to reinitialize stack object again when encountering this. Any idea what change may cause it? It didn't happen in 1.4 for our live environment.ishaileshmishra commentedon Feb 16, 2022
@zxm5010
1 - You don't need to add environment as a query param. we handle it internally.
2 - We are looking into it the issue you are getting api_key error.
We are trying to reproduce the said issue at our end
zxm5010 commentedon Feb 17, 2022
@ishaileshmishra
1 - Quick clarification, we are always getting
"error_message":"Failed to fetch entries. Please try again with valid parameters.","error_code":141,"errors":{"environment":["is required."]}}after the firstfetchrequest, unless if we set header explicitly. I think there's something overwrites stack's context/header internally when we do fetches. Maybe it also relates to api_key errorFor more context, we are fetching nested contents. And, nested fetches are called in the onCompletion method.
Example:
Not sure if there's any behavior changes internally how the requests getting handled, but the logic mentioned above behaves fine in version 1.4.x, but start to behave unstable in 1.8.x
🐛 #47 fixed environment issue
ishaileshmishra commentedon Mar 16, 2022
@zxm5010 Please update your contentstack-java dependency to v1.9.0,
Feel free to reopen the issue if your issue is not resolved.