-
Notifications
You must be signed in to change notification settings - Fork 968
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
[MD] Add endpoint validation to create data source API #6631
[MD] Add endpoint validation to create data source API #6631
Conversation
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6631 +/- ##
===========================================
+ Coverage 32.93% 67.80% +34.87%
===========================================
Files 2260 3413 +1153
Lines 45769 66755 +20986
Branches 7200 10861 +3661
===========================================
+ Hits 15075 45266 +30191
+ Misses 29984 18845 -11139
- Partials 710 2644 +1934
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
abd7ffd
to
ec2f7c8
Compare
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
ec2f7c8
to
27f9ad5
Compare
Probably better to remove the credentials or modify the recording to hide it |
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.
Left nonblocking comment
throw SavedObjectsErrorHelpers.createBadRequestError( | ||
'"title" attribute must be a non-empty string' | ||
); | ||
} | ||
|
||
if (title.length > 32) { |
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.
nit: could we make this a constant with a meaningful name?
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.
updated to use constant
@@ -61,16 +61,24 @@ export class DataSourcePlugin implements Plugin<DataSourcePluginSetup, DataSourc | |||
const cryptographyServiceSetup: CryptographyServiceSetup = this.cryptographyService.setup( | |||
config | |||
); | |||
const dataSourceService: DataSourceServiceSetup = await this.dataSourceService.setup(config); |
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.
Should we name it dataSourceServiceSetUp as cryptographyServiceSetup
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.
fixed
if (!auth) { | ||
throw SavedObjectsErrorHelpers.createBadRequestError('"auth" attribute is required'); | ||
} | ||
|
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.
So from now on, we cannot choose no auth?
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.
Just a general thought. I see the error is 'Creation of the Data Source failed with some errors.'. Not sure if we need to give more specifc error in different error cases such as |
Signed-off-by: Zhongnan Su <szhongna@amazon.com>
809af74
to
6121267
Compare
The error message is the existing behavior when failing to create data source , with/without my change, I agree we should improve by displaying the error with details to user. It could be a separate task to work on, and it should take care of both test connection and create data source |
I remember datasource is able to be created even test connection failed used to be the expected behavior. |
AFAIK, yes, is there any concern? @xinruiba |
No concerns if that's by design~ |
testClientDataSourceAttr: attributes as DataSourceAttributes, | ||
authRegistry: await this.authRegistryPromise, | ||
customApiSchemaRegistryPromise: this.customApiSchemaRegistryPromise, | ||
}); |
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.
Thanks for this change.
Are there any chances we can reuse this function: https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/data_source_management/public/components/utils.ts#L206?
Since datasource and datasource_management plugin will both exist in the same time, so the validation path in datasource_management plugin should always been routed.
Then we depend on sending request to /internal/data-source-management/validate
to test connection instead of creating a new datasource client here.
What do you think?
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.
Do you mean when user click create data source button, we first call /internal/data-source-management/validate
to validate and then call create data source API? @xinruiba
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.
Yes
Pros:
- We rely on the URL for data source validation.
Cons:
- If customers directly create a data source by calling the URL (using curl), the data source validation will be bypassed.
I'll leave the decision to you~
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.
Yes, the cons you mentioned is exactly the reason I choose to add validation to the saved object create data source API, this will almost make sure no invalid endpoint can be created as a data source. I use "almost", cuz user can still directly write data into .kibana
index
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.
Sounds good to me. Approving~
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.
Non blocking comment.
Maybe a question to designer. Since we already do validation as a part of datasource creation. Do we sill need a separate test connection before clicking on datasource creation?
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.
good point, @kgcreative @xeniatup, I wonder what's your thought on this
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.
Given the updated validation, i don't think we need it in the create page.
Signed-off-by: Zhongnan Su <szhongna@amazon.com> (cherry picked from commit 0c114ce) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: Zhongnan Su <szhongna@amazon.com> (cherry picked from commit 0c114ce) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…#6631) Signed-off-by: Zhongnan Su <szhongna@amazon.com>
Description
Add endpoint validation to create data source API, by testing if endpoint is reachable, using the same logic as what's behind "test connection" feature
Issues Resolved
#6517
Screenshot
Testing the changes
Changelog
Check List
yarn test:jest
yarn test:jest_integration