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

oem-ibm: Handle the json parse exception correctly #621

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

jaypadath
Copy link
Contributor

This commit handles the CoD license json parsing exception by correctly catching it and returs the error to the caller. Also made the change to avoid the removal of license json file whenever shared by the host.

Tested:
Done the sanity testing to verify that json file was kept without removal.

@jaypadath jaypadath force-pushed the 655145_lic_parse_error branch from f0df9cc to dd2c4fb Compare October 10, 2024 10:42
if (dataNew.is_discarded())
try
{
dataNew = Json::parse(jsonFileNew);
Copy link
Contributor

Choose a reason for hiding this comment

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

define dataNew here itself? auto dataNew

Copy link
Contributor Author

@jaypadath jaypadath Oct 10, 2024

Choose a reason for hiding this comment

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

We need to use this dataNew after try-catch, so can't use auto here

{
error("Failed to parse the new license json file '{NEW_LIC_JSON}'",
"NEW_LIC_JSON", newLicJsonFilePath);
throw InternalFailure();
return PLDM_ERROR;
Copy link
Contributor

Choose a reason for hiding this comment

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

return PLDM_ERROR_INVALID_DATA ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if (dataNew.is_discarded())
try
{
dataNew = Json::parse(jsonFileNew);
Copy link
Contributor

Choose a reason for hiding this comment

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

Jay, no need of other two parameters? (nullptr and false)

Copy link
Contributor Author

@jaypadath jaypadath Oct 10, 2024

Choose a reason for hiding this comment

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

Not needed as they are the default args with values as nullptr and true. In fact the intention is to change the third argument to true which matches with default value.

@jaypadath jaypadath force-pushed the 655145_lic_parse_error branch from dd2c4fb to 7d0c250 Compare October 10, 2024 11:18
@jaypadath
Copy link
Contributor Author

jenkins run tests please

Comment on lines +138 to +144
info("Setting Pending Attributes {NUMBER}", "NUMBER",
(int)pendingAttributes.size());
Copy link
Contributor

Choose a reason for hiding this comment

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

can't we print the attribute names here ? size might not give much clues if we hit this path.

@jaypadath jaypadath force-pushed the 655145_lic_parse_error branch from 7d0c250 to a5254e8 Compare October 10, 2024 12:52
This commit handles the CoD license json parsing exception by
correctly catching it and returns the error to the caller. Also
made the change to avoid the removal of license json file whenever
shared by the host.

Tested:
Done the sanity testing to verify that json file was kept without
removal.

Signed-off-by: Jayashankar Padath <[email protected]>
@jaypadath jaypadath force-pushed the 655145_lic_parse_error branch from a5254e8 to 266ad67 Compare October 10, 2024 12:55
@rfrandse rfrandse merged commit 67ab8d5 into ibm-openbmc:1110 Oct 10, 2024
1 check passed
@jaypadath jaypadath deleted the 655145_lic_parse_error branch November 4, 2024 18:31
ArchanaKakani pushed a commit to ArchanaKakani/pldm that referenced this pull request Dec 10, 2024
This commit handles the CoD license json parsing exception by
correctly catching it and returns the error to the caller. Also
made the change to avoid the removal of license json file whenever
shared by the host.

Tested:
Done the sanity testing to verify that json file was kept without
removal.

Signed-off-by: Jayashankar Padath <[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