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 typo cause it will always trigger JSON11 parse #889

Merged
merged 3 commits into from
Oct 30, 2024

Conversation

Hailong-am
Copy link
Contributor

@Hailong-am Hailong-am commented Oct 29, 2024

Description

Fix typo cause it will always trigger JSON11 parse.

if the json string has number in it, numeralsAreNumbers will always be true.

(val < Number.MAX_SAFE_INTEGER || val > Number.MAX_SAFE_INTEGER)

should changed to (val < Number.MIN_SAFE_INTEGER || val > Number.MAX_SAFE_INTEGER)

if (
numeralsAreNumbers &&
typeof val === 'number' &&
(val < Number.MAX_SAFE_INTEGER || val > Number.MAX_SAFE_INTEGER)
) {
numeralsAreNumbers = false;
}

then it will always trigger JSON11 parse

if (shouldHandleLongNumerals && !numeralsAreNumbers) {
try {
const temp = JSON11.parse(json, null, { withLongNumerals: true });
if (temp) {
object = temp;
}
} catch (ex) {
// Do nothing: sjson.parse succeeded but JSON11.parse failed; return the sjson.parse result
}
}

Issues Resolved

List any issues this PR will resolve, e.g. Closes [...].

Check List

  • New functionality includes testing.
    • All tests pass
  • Linter check was successfull - yarn run lint doesn't show any errors
  • Commits are signed per the DCO using --signoff
  • Changelog was updated.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Hailong Cui <[email protected]>
Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

Thanks, could you please add a test?

@AMoo-Miki
Copy link
Collaborator

Thanks, could you please add a test?

Since we have positive tests, we should add negative tests.

Signed-off-by: Hailong Cui <[email protected]>
@Hailong-am
Copy link
Contributor Author

Thanks, could you please add a test?

Since we have positive tests, we should add negative tests.

Thanks, a negative tests added. @dblock @AMoo-Miki

@dblock dblock merged commit b096274 into opensearch-project:main Oct 30, 2024
52 of 54 checks passed
@AMoo-Miki
Copy link
Collaborator

OSD needs this in 2.x. It would be great if we had a release for it too.

AMoo-Miki added a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Nov 9, 2024
AMoo-Miki added a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Nov 10, 2024
@nhtruong
Copy link
Collaborator

I'll cut a release today

@nhtruong
Copy link
Collaborator

AMoo-Miki added a commit to opensearch-project/OpenSearch-Dashboards that referenced this pull request Nov 15, 2024
…JS client (#8839)

* [@osd/std] Fix typo while inspecting values for large numerals

Signed-off-by: Miki <[email protected]>

* Patch @opensearch-project/opensearch to fix a typo

Ref: opensearch-project/opensearch-js#889

Signed-off-by: Miki <[email protected]>

* Changeset file for PR #8839 created/updated

---------

Signed-off-by: Miki <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit to opensearch-project/OpenSearch-Dashboards that referenced this pull request Nov 15, 2024
…JS client (#8839)

* [@osd/std] Fix typo while inspecting values for large numerals

Signed-off-by: Miki <[email protected]>

* Patch @opensearch-project/opensearch to fix a typo

Ref: opensearch-project/opensearch-js#889

Signed-off-by: Miki <[email protected]>

* Changeset file for PR #8839 created/updated

---------

Signed-off-by: Miki <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit e993d24)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
AMoo-Miki added a commit to opensearch-project/OpenSearch-Dashboards that referenced this pull request Dec 11, 2024
…in OSD and the JS client (#8875)

* Fix a typo while inspecting values for large numerals in OSD and the JS client (#8839)

* [@osd/std] Fix typo while inspecting values for large numerals

Signed-off-by: Miki <[email protected]>

* Patch @opensearch-project/opensearch to fix a typo

Ref: opensearch-project/opensearch-js#889

Signed-off-by: Miki <[email protected]>

* Changeset file for PR #8839 created/updated

---------

Signed-off-by: Miki <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit e993d24)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Update postinstall.js

Signed-off-by: Miki <[email protected]>

---------

Signed-off-by: Miki <[email protected]>
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>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Miki <[email protected]>
opensearch-trigger-bot bot pushed a commit to opensearch-project/OpenSearch-Dashboards that referenced this pull request Dec 11, 2024
…in OSD and the JS client (#8875)

* Fix a typo while inspecting values for large numerals in OSD and the JS client (#8839)

* [@osd/std] Fix typo while inspecting values for large numerals

Signed-off-by: Miki <[email protected]>

* Patch @opensearch-project/opensearch to fix a typo

Ref: opensearch-project/opensearch-js#889

Signed-off-by: Miki <[email protected]>

* Changeset file for PR #8839 created/updated

---------

Signed-off-by: Miki <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit e993d24)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Update postinstall.js

Signed-off-by: Miki <[email protected]>

---------

Signed-off-by: Miki <[email protected]>
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>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Miki <[email protected]>
(cherry picked from commit cd2faad)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit to opensearch-project/OpenSearch-Dashboards that referenced this pull request Dec 11, 2024
…in OSD and the JS client (#8875)

* Fix a typo while inspecting values for large numerals in OSD and the JS client (#8839)

* [@osd/std] Fix typo while inspecting values for large numerals

Signed-off-by: Miki <[email protected]>

* Patch @opensearch-project/opensearch to fix a typo

Ref: opensearch-project/opensearch-js#889

Signed-off-by: Miki <[email protected]>

* Changeset file for PR #8839 created/updated

---------

Signed-off-by: Miki <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit e993d24)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Update postinstall.js

Signed-off-by: Miki <[email protected]>

---------

Signed-off-by: Miki <[email protected]>
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>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Miki <[email protected]>
(cherry picked from commit cd2faad)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit to opensearch-project/OpenSearch-Dashboards that referenced this pull request Dec 11, 2024
…in OSD and the JS client (#8875)

* Fix a typo while inspecting values for large numerals in OSD and the JS client (#8839)

* [@osd/std] Fix typo while inspecting values for large numerals

Signed-off-by: Miki <[email protected]>

* Patch @opensearch-project/opensearch to fix a typo

Ref: opensearch-project/opensearch-js#889

Signed-off-by: Miki <[email protected]>

* Changeset file for PR #8839 created/updated

---------

Signed-off-by: Miki <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit e993d24)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Update postinstall.js

Signed-off-by: Miki <[email protected]>

---------

Signed-off-by: Miki <[email protected]>
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>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Miki <[email protected]>
(cherry picked from commit cd2faad)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
AMoo-Miki added a commit to opensearch-project/OpenSearch-Dashboards that referenced this pull request Dec 11, 2024
…in OSD and the JS client (#8875) (#9037)

* Fix a typo while inspecting values for large numerals in OSD and the JS client (#8839)

* [@osd/std] Fix typo while inspecting values for large numerals



* Patch @opensearch-project/opensearch to fix a typo

Ref: opensearch-project/opensearch-js#889



* Changeset file for PR #8839 created/updated

---------



(cherry picked from commit e993d24)


* Update postinstall.js



---------






(cherry picked from commit cd2faad)

Signed-off-by: Miki <[email protected]>
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>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Miki <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants