OpenSearch-Dashboards
OpenSearch-Dashboards copied to clipboard
[BUG] Test connection failed on creating datasource will cause page refresh
Describe the bug when create a datasource with wrong credential, click on test connection it will reports error and refresh the page, all input disappears.
https://github.com/opensearch-project/OpenSearch-Dashboards/assets/113890546/6f7ce6d6-b114-4ed3-a821-c3da97b6fd30
To Reproduce Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior
Page should not refreshed and user could fix the wrong credential
OpenSearch Version Please list the version of OpenSearch being used.
Dashboards Version Please list the version of OpenSearch Dashboards being used.
Plugins
Please list all plugins currently enabled.
Screenshots
If applicable, add screenshots to help explain your problem.
Host/Environment (please complete the following information):
- OS: [e.g. iOS]
- Browser and version [e.g. 22]
Additional context
Add any other context about the problem here.
@Hailong-am Hi Hailong, I couldn't reproduce the issue on both playground, and future playground. Could you check again? It might be some network or browser issue?
@Hailong-am Hi Hailong, I couldn't reproduce the issue on both playground, and future playground. Could you check again? It might be some network or browser issue?
try with Incognito mode issue still exists, i am using google account to login.
Here is the validate request and response. you can try with endpoint https://search-hailong-test-2-uvr7cern4rw5is7wn222wif6vy.ap-northeast-3.es.amazonaws.com
with incorrect credential.
I guess the cause might be the response status code is 401 causing page refresh.
@Hailong-am Yes, security dashboards plugin has logic to reload if there's a 401 detected on the page, even though the 401 is from data source connection, not local cluster. https://github.com/opensearch-project/security-dashboards-plugin/blob/67397ec2c211d98be0ca133193a3e64782b91243/public/utils/logout-utils.tsx#L42
That's why in MDS(Multiple data source) we have logic to cast 401 to 400, to avoid page reload. https://github.com/opensearch-project/OpenSearch-Dashboards/blob/cfe7cd1e979dc25dad8bd1b01fe489e42859fc39/src/plugins/data_source/server/lib/error.ts#L48-L64
Since you still get 401, I assume you are using 2.11.0 AOS domain. Because in 2.11, a bug was introduced in security plugin, which drops the body: "Unauthorized"
for 401 unauthorized response https://github.com/opensearch-project/security/issues/3803. And this will cause MDS fails to cast 401 to 400, and return the 401 to the client side, leading to a page reload
I saw a fix https://github.com/opensearch-project/security/pull/4233 was delivered by @cwperks , Craig, should this fix be backported to 2.11, and do a patch release?
That's why in MDS(Multiple data source) we have logic to cast 401 to 400, to avoid page reload.
@zhongnansu thanks for the detail. Just curious about the convert 401 to 400 logic, that depends on the response must have body and status code is 401. If I have a endpoint(not opensearch)/proxy service for OpenSearch return 401 without body, will that still works?
@Hailong-am Based on the source code, the body, header and status code needs to exist, https://github.com/opensearch-project/OpenSearch-Dashboards/blob/32fbe1876102dbeb613b122b6d08ce020c87542b/src/plugins/data_source/server/lib/error.ts#L62.
@zhongnansu Do we know why we need this check?
const isResponseError = (error: any): error is ResponseError => {
return Boolean(error.body && error.statusCode && error.headers);
};
Hi Team Still seeing this error. On the future playground / data sources and choose test_with_other_obj. The page refreshes everytime i click test connection.
Hi Team Still seeing this error. On the future playground / data sources and choose test_with_other_obj. The page refreshes everytime i click test connection
test_with_other_obj
data source is using 2.11 OpenSearch that comes with the security plugin bug, causing the page refresh.