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

Command with query parameter reports unrecognized parameter in DevTools #3813

Merged
merged 1 commit into from
Apr 12, 2023

Conversation

Hailong-am
Copy link
Collaborator

@Hailong-am Hailong-am commented Apr 10, 2023

Description

check whether the command has a query parameter or not first, if it has, then append &pretty=true instead of?pretty=true

Issues Resolved

#3812

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
    • yarn test:ftr
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

@codecov-commenter
Copy link

codecov-commenter commented Apr 10, 2023

Codecov Report

Merging #3813 (d3d3418) into main (be47d9a) will increase coverage by 0.00%.
The diff coverage is 80.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@           Coverage Diff           @@
##             main    #3813   +/-   ##
=======================================
  Coverage   66.41%   66.42%           
=======================================
  Files        3209     3209           
  Lines       61730    61732    +2     
  Branches     9533     9533           
=======================================
+ Hits        41000    41004    +4     
+ Misses      18442    18440    -2     
  Partials     2288     2288           
Flag Coverage Δ
Linux 66.36% <80.00%> (+<0.01%) ⬆️
Windows 66.37% <80.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
.../server/routes/api/console/proxy/create_handler.ts 69.76% <80.00%> (+1.47%) ⬆️

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@joshuarrrr joshuarrrr changed the title Command with query parameter reports reports unrecognized parameter in DevTools Command with query parameter reports unrecognized parameter in DevTools Apr 10, 2023
@zhongnansu zhongnansu self-requested a review April 10, 2023 17:11
Comment on lines 78 to 82
if (urlPath.includes('?')) {
urlPath += '&pretty=true';
} else {
urlPath += '?pretty=true';
}
Copy link
Member

@zhongnansu zhongnansu Apr 10, 2023

Choose a reason for hiding this comment

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

Thanks @Hailong-am for submitting the issue and post PR to fix!

What do you think of rewriting this toUrlPath() function to the below code? I think this will handle most corner cases.

function toUrlPath(path: string) {
  const FAKE_BASE = 'http://localhost';
  const urlWithFakeBase = new URL(`${FAKE_BASE}/${trimStart(path, '/')}`);
  // Appending pretty here to have OpenSearch do the JSON formatting, as doing
  // in JS can lead to data loss (7.0 will get munged into 7, thus losing indication of
  // measurement precision)
  if (!urlWithFakeBase.searchParams.get('pretty')) {
    urlWithFakeBase.searchParams.append('pretty', 'true');
  }
  const urlPath = urlWithFakeBase.href.replace(urlWithFakeBase.origin, '');
  return urlPath;
}

Copy link
Collaborator Author

@Hailong-am Hailong-am Apr 11, 2023

Choose a reason for hiding this comment

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

this looks much better and clear, update the change by your suggestion.

@zhongnansu zhongnansu linked an issue Apr 10, 2023 that may be closed by this pull request
@zhongnansu zhongnansu added Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry console labels Apr 10, 2023
Signed-off-by: Hailong Cui <ihailong@amazon.com>
Copy link
Member

@zhongnansu zhongnansu left a comment

Choose a reason for hiding this comment

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

Thanks for the change, lgtm!

@zhongnansu
Copy link
Member

@kristenTian would you give a second review?

@zhongnansu zhongnansu requested a review from kristenTian April 11, 2023 00:54
@zhongnansu zhongnansu removed the Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry label Apr 11, 2023
@zhongnansu zhongnansu linked an issue Apr 11, 2023 that may be closed by this pull request
Copy link
Member

@manasvinibs manasvinibs left a comment

Choose a reason for hiding this comment

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

LGTM. Will wait for windows CI check failures to pass before merging.

@zhongnansu zhongnansu merged commit e12ae0b into opensearch-project:main Apr 12, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 12, 2023
Signed-off-by: Hailong Cui <ihailong@amazon.com>
(cherry picked from commit e12ae0b)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
joshuarrrr pushed a commit that referenced this pull request Apr 12, 2023
Signed-off-by: Hailong Cui <ihailong@amazon.com>
(cherry picked from commit e12ae0b)
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>
sikhote pushed a commit to sikhote/OpenSearch-Dashboards that referenced this pull request Apr 24, 2023
…ject#3813)

Signed-off-by: Hailong Cui <ihailong@amazon.com>
Signed-off-by: David Sinclair <david@sinclair.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants