Skip to content

common: ocispec: return integrity error on file read - #326

Merged
al1img merged 1 commit into
aosedge:feature_imagemanagerfrom
al1img:integrity
Nov 6, 2026
Merged

al1img merged 1 commit into
aosedge:feature_imagemanagerfrom
al1img:integrity

Conversation

@al1img

@al1img al1img commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Integrity recovery is triggered by eIntegrity, but the OCI spec loaders read files with std::ifstream, which doesn't report read errors: a failed read ends up as a JSON parse error.

Add utils::ReadJsonFromFile, which reads the file with fs::ReadFile and parses its content, and use it in all the loaders. EIO and EBADMSG are returned as eIntegrity, ENOENT as eNotFound, any other errno as is. Malformed JSON that is read successfully is still returned as eInvalidArgument.

This change requires fs::ReadFile of aos_core_lib_cpp that returns eIntegrity and eNotFound.

Copilot AI balanced review requested due to automatic review settings November 5, 2026 08:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@MykolaSuperman MykolaSuperman left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed-by: Mykola Solianko <mykola_solianko@epam.com>

@mlohvynenko mlohvynenko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>

Integrity recovery is triggered by eIntegrity, but the OCI spec loaders read
files with std::ifstream, which doesn't report read errors: a failed read
ends up as a JSON parse error.

Add utils::ReadJsonFromFile, which reads the file with fs::ReadFile and parses
its content, and use it in all the loaders. EIO and EBADMSG are returned as
eIntegrity, ENOENT as eNotFound, any other errno as is. Malformed JSON that
is read successfully is still returned as eInvalidArgument.

This change requires fs::ReadFile of aos_core_lib_cpp that returns eIntegrity
and eNotFound.

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>
Reviewed-by: Mykola Solianko <mykola_solianko@epam.com>
Copilot AI balanced review requested due to automatic review settings November 6, 2026 18:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@al1img
al1img merged commit 3cbae37 into aosedge:feature_imagemanager Nov 6, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants