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

[BUG] Test connection failed on creating datasource will cause page refresh #6667

Open
Hailong-am opened this issue Apr 28, 2024 · 4 comments
Labels
bug Something isn't working multiple datasource multiple datasource project

Comments

@Hailong-am
Copy link
Contributor

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.

create_ds.mov

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. 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 Hailong-am added bug Something isn't working untriaged labels Apr 28, 2024
@zhongnansu
Copy link
Member

@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?

@zhongnansu zhongnansu added needs more info Requires more information from poster multiple datasource multiple datasource project and removed untriaged labels Apr 29, 2024
@Hailong-am
Copy link
Contributor Author

Hailong-am commented Apr 30, 2024

@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.

image

@zhongnansu
Copy link
Member

zhongnansu commented Apr 30, 2024

@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.

// cast OpenSearch client 401 response error to 400, due to https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2591
if (isResponseError(error) && error.statusCode === 401) {
return new DataSourceError(error, JSON.stringify(error.meta.body), 400);
}
// cast legacy client 401 response error to 400
if (error instanceof LegacyErrors.AuthenticationException) {
return new DataSourceError(error, error.message, 400);
}
// handle all other error that may or may not comes with statuscode
return new DataSourceError(error, message);
};
const isResponseError = (error: any): error is ResponseError => {
return Boolean(error.body && error.statusCode && error.headers);
};

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 opensearch-project/security#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 opensearch-project/security#4233 was delivered by @cwperks , Craig, should this fix be backported to 2.11, and do a patch release?

@zhongnansu zhongnansu removed the needs more info Requires more information from poster label Apr 30, 2024
@Hailong-am
Copy link
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working multiple datasource multiple datasource project
Projects
None yet
Development

No branches or pull requests

2 participants