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

fix: Dev tools console autocomplete issue #5567 #5568

Merged
merged 5 commits into from
Dec 14, 2023

Conversation

kishor82
Copy link
Contributor

@kishor82 kishor82 commented Dec 3, 2023

Description

Resolves a bug in the Console Plugin Dev Tool where the retrieveSettings function was incorrectly called with 'fields' instead of 'indices'. for retrieveAliases function.

Issues Resolved

closes #5567

Screenshot

Screenshot

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link

codecov bot commented Dec 3, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (9ba5cf5) 66.98% compared to head (2500f83) 67.02%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5568      +/-   ##
==========================================
+ Coverage   66.98%   67.02%   +0.03%     
==========================================
  Files        3293     3294       +1     
  Lines       63294    63296       +2     
  Branches    10067    10066       -1     
==========================================
+ Hits        42396    42422      +26     
+ Misses      18458    18431      -27     
- Partials     2440     2443       +3     
Flag Coverage Δ
Linux_1 35.24% <ø> (ø)
Linux_2 55.17% <ø> (ø)
Linux_3 43.87% <100.00%> (+0.07%) ⬆️
Linux_4 35.34% <ø> (ø)
Windows_1 35.27% <ø> (ø)
Windows_2 55.14% <ø> (ø)
Windows_3 43.89% <100.00%> (+0.08%) ⬆️
Windows_4 35.34% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kishor82 kishor82 force-pushed the fix/5567 branch 6 times, most recently from f6a4bdd to b3c82b4 Compare December 7, 2023 05:32
Copy link
Member

@joshuarrrr joshuarrrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kishor82 Thanks for the fix! Just a couple minor questions and suggestions.

Comment on lines 79 to 83
interface SettingKeyToPathMap {
fields: '_mapping';
indices: '_aliases';
templates: '_template';
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to define this as an interface? It seems like it would be simpler to just define the const here, instead of within the retrieveSettings scope:

Suggested change
interface SettingKeyToPathMap {
fields: '_mapping';
indices: '_aliases';
templates: '_template';
}
const SETTING_KEY_TO_PATH_MAP = {
fields: '_mapping';
indices: '_aliases';
templates: '_template';
} as const;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it would be simpler to define it as a constant. I initially set it up for potential usage in tests and other functions, but it turned out to be unnecessary.

Promise.allSettled([
retrieveMappings(http, settingsToRetrieve, dataSourceId),
retrieveAliases(http, settingsToRetrieve, dataSourceId),
retrieveTemplates(http, settingsToRetrieve, dataSourceId),
]).then(() => {
]).then((res) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this? If so, I think our style would generally be

Suggested change
]).then((res) => {
]).then((_res) => {

to hint that it's unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer require this. I added a console while testing and forgot to remove it.

@@ -330,13 +336,8 @@ function retrieveSettings(
if (settingsToRetrieve[settingsKey] === true) {
return opensearch.send(http, 'GET', settingKeyToPathMap[settingsKey], null, dataSourceId);
} else {
if (settingsToRetrieve[settingsKey] === false) {
// If the user doesn't want autocomplete suggestions, then clear any that exist
return Promise.resolve({});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we want to change this response shape?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check settingsToRetrieve[settingsKey] === false is unnecessary, so I have removed it. Additionally, in the else condition, the response body doesn't matter, whether it's undefined or {}, as long as it's not an instance of HttpResponse.

headers: Array<[string, string]>
): Response => {
return {
// headers: {} as Headers,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Suggested change
// headers: {} as Headers,

Copy link
Member

@joshuarrrr joshuarrrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kishor82 Thanks for all the fixes! I pulled it down locally and reproduced your demo - LGTM!

@kishor82 kishor82 force-pushed the fix/5567 branch 3 times, most recently from 62afa55 to 8a244f4 Compare December 13, 2023 23:24
Signed-off-by: Kishor Rathva <kishorrathva8298@gmail.com>
Signed-off-by: Kishor Rathva <kishorrathva8298@gmail.com>
Signed-off-by: Kishor Rathva <kishorrathva8298@gmail.com>
Signed-off-by: Kishor Rathva <kishorrathva8298@gmail.com>
Signed-off-by: Kishor Rathva <kishorrathva8298@gmail.com>
@ananzh
Copy link
Member

ananzh commented Dec 14, 2023

Also verified on 1.3.
1.3 has no issue. No backport to 1.3.

@ananzh ananzh added the bug Something isn't working label Dec 14, 2023
@ananzh ananzh merged commit a5c45a3 into opensearch-project:main Dec 14, 2023
69 of 70 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Dec 14, 2023
* fix: Dev tools console autocomplete issue #5567
* Added CHANGELOG
* Added test for retrieveAutoCompleteInfo
* Refactored tests
* Added suggested changes.
---------

Signed-off-by: Kishor Rathva <kishorrathva8298@gmail.com>
(cherry picked from commit a5c45a3)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
manasvinibs pushed a commit that referenced this pull request Dec 14, 2023
* fix: Dev tools console autocomplete issue #5567
* Added CHANGELOG
* Added test for retrieveAutoCompleteInfo
* Refactored tests
* Added suggested changes.
---------


(cherry picked from commit a5c45a3)

Signed-off-by: Kishor Rathva <kishorrathva8298@gmail.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Dev tools console autocomplete doesn't work well with aliases
3 participants