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(rest-api): Avoid panic in append_info_headers #4178

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

jkrvivian
Copy link
Contributor

@jkrvivian jkrvivian commented Nov 21, 2024

Description of change

The REST API might cause the node to panic if append_info_headers fails to retrieve the data. This PR updates append_info_headers to return an internal server error when it fails.

Links to any relevant issues

Close #4087

Type of change

  • Bug fix

Change checklist

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have checked that new and existing unit tests pass locally with my changes

@jkrvivian jkrvivian added the team-core-node Issues related to the Core Node team label Nov 21, 2024
@jkrvivian jkrvivian self-assigned this Nov 21, 2024
@jkrvivian jkrvivian requested review from a team as code owners November 21, 2024 13:57
*checkpoint.sequence_number(),
checkpoint.timestamp_ms,
),
Err(_) => (0, 0, 0),
Copy link
Member

Choose a reason for hiding this comment

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

Instead of ignoring the error, it might be better to return it from this function. Overriding the error with (0,0,0) doesn't seem good to me, also because it might be an important error from the state reader.

Comment on lines 131 to 133
pub enum HeaderError {
InternalServerError(String),
}
Copy link
Contributor

@bingyanglin bingyanglin Nov 25, 2024

Choose a reason for hiding this comment

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

I am not very sure whether it is necessary to introduce a new HeaderError, or maybe you can just use the RestErrordefined in the iota-rest-api crate?

@semenov-vladyslav
Copy link
Contributor

It seems that this issue was already fixed in the upstream. They just ignore the header if the corresponding object is not found instead of failing with internal server error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-core-node Issues related to the Core Node team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

node crash when requesting RESTful API before initial checkpoint sync completes
5 participants