Skip to content

common: inf and NaN are invalid in JSON#57695

Closed
sajibreadd wants to merge 2 commits intoceph:mainfrom
sajibreadd:wip-66215
Closed

common: inf and NaN are invalid in JSON#57695
sajibreadd wants to merge 2 commits intoceph:mainfrom
sajibreadd:wip-66215

Conversation

@sajibreadd
Copy link
Member

@sajibreadd sajibreadd commented May 24, 2024

Fixes: https://tracker.ceph.com/issues/66215

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@sebastian-philipp
Copy link
Contributor

@batrick do you want to review this?

@sajibreadd sajibreadd force-pushed the wip-66215 branch 2 times, most recently from 3468f5a to 81e2164 Compare May 24, 2024 17:35
Copy link
Member

@batrick batrick left a comment

Choose a reason for hiding this comment

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

Commit title JSON Parser does not allow inf and NaN. Converted it to null. to common/Formatter: dump inf/nan as strings

@sajibreadd
Copy link
Member Author

sajibreadd commented May 29, 2024

Is this PR going for the test? Also I think we need to backport this PR. #57392
PR is a dependency for my commit to be backported. So we need to cherr-pick both commits.

@batrick batrick changed the title inf and NaN are invalid in JSON common: inf and NaN are invalid in JSON May 31, 2024
@batrick batrick requested review from a team and removed request for patrakov and sebastian-philipp May 31, 2024 16:07
@batrick
Copy link
Member

batrick commented May 31, 2024

jenkins test make check arm64

template <class T>
void JSONFormatter::add_value(std::string_view name, double val) {
CachedStackStringStream css;
if (std::isinf(val) || std::isnan(val)) {

Choose a reason for hiding this comment

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

Would the shorter !std::isfinite(val) form work here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, missed your comment somehow.
It does work but do you have any special observation for using that instead of std::isinf(val) ?

Copy link

Choose a reason for hiding this comment

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

It's shorter, expresses the intent more directly, enumerates goodness not badness,... i.e. purely aesthetical reasons.

@sajibreadd
Copy link
Member Author

jenkins test make check

@sajibreadd
Copy link
Member Author

jenkins test docs

@sajibreadd
Copy link
Member Author

jenkins test api

@sajibreadd
Copy link
Member Author

jenkins test windows

@sajibreadd
Copy link
Member Author

jenkins test make check arm64

@sajibreadd
Copy link
Member Author

jenkins test api

Copy link
Member

@batrick batrick left a comment

Choose a reason for hiding this comment

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

minor nits, otherwise lgtm

void add_value(std::string_view name, double val);

template <class T>
template <typename T>
Copy link
Member

Choose a reason for hiding this comment

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

undo please

}
}

template <class T>
Copy link
Member

Choose a reason for hiding this comment

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

undo this change

EXPECT_EQ(parser.find_obj("negative_infinity")->get_data(), "null");
EXPECT_EQ(parser.find_obj("nan_val")->get_data(), "null");
EXPECT_EQ(parser.find_obj("nan_val_alt")->get_data(), "null");
} No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

missing terminal newline

Fixes: https://tracker.ceph.com/issues/66215
Signed-off-by: Md Mahamudur Rahaman Sajib <mahamudur.sajib@croit.io>
@sajibreadd
Copy link
Member Author

jenkins test make check

1 similar comment
@sajibreadd
Copy link
Member Author

jenkins test make check

@sajibreadd
Copy link
Member Author

jenkins test api

@sajibreadd
Copy link
Member Author

@batrick Is there anything I need to do in this PR?

EXPECT_EQ(parser.find_obj("negative_infinity")->get_data(), "null");
EXPECT_EQ(parser.find_obj("nan_val")->get_data(), "null");
EXPECT_EQ(parser.find_obj("nan_val_alt")->get_data(), "null");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

please verify double_max/double_min values as well

@sajibreadd sajibreadd closed this Jul 15, 2024
@sajibreadd sajibreadd deleted the wip-66215 branch July 15, 2024 14:12
@batrick
Copy link
Member

batrick commented Jul 15, 2024

@sajibreadd did you mean to close this? Please reopen?

@sajibreadd
Copy link
Member Author

@sajibreadd did you mean to close this? Please reopen?

Here is some mistake I did. I merged main into the branch by mistake(by syncing the fork by mistake). As there is a lot of commit to drop that's why here is the things I have done,

  1. created a new branch.
  2. cherrypicked the commit.
  3. pushed the branch upstream
  4. deleted the old branch named wip-66215
  5. renamed the newly created branch wip-66215

Now github is not allowing me to reopen the PR. Apologies for the mistakes. Now what should be the best things to do? create another PR and have reference of this PR?

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.

5 participants