Skip to content

Conversation

@Standing-Man
Copy link
Contributor

Which issue does this PR close?

What changes are included in this PR?

Avoid storing error message on snapshot, return error instead.

Are these changes tested?

Yes

…shot

Signed-off-by: StandingMan <jmtangcs@gmail.com>
@Standing-Man
Copy link
Contributor Author

@CTTY and @yshcz ready to review.

Copy link
Collaborator

@CTTY CTTY left a comment

Choose a reason for hiding this comment

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

Hi @Standing-Man , thanks for the contribution! Looks good overall, I just have some minor feedbacks

(Some(_), Some(_)) => {
return Err(Error::new(
ErrorKind::Unexpected,
"v1 snapshot invariant violated: manifest_list and manifests are both set",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"v1 snapshot invariant violated: manifest_list and manifests are both set",
"Invalid v1 snapshot, when manifest list provided, manifest files should be omitted",

I think the original error message is more specific

(None, _) => {
return Err(Error::new(
ErrorKind::FeatureUnsupported,
"v1 snapshot invariant violated: manifest_list is missing",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"v1 snapshot invariant violated: manifest_list is missing",
"Unsupported v1 snapshot, only manifest list is supported",

Same here, the original message is more specific

},
(Some(_), Some(_)) => {
return Err(Error::new(
ErrorKind::Unexpected,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ErrorKind::Unexpected,
ErrorKind::DataInvalid,

Referring to the v3 parsing and error handling logic here, DataInvlid seems more apporpriate

}
(None, _) => {
return Err(Error::new(
ErrorKind::FeatureUnsupported,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ErrorKind::FeatureUnsupported,
ErrorKind::DataInvalid,

Same here

"#;

let result = serde_json::from_str::<TableMetadata>(metadata);
assert!(result.is_err());
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should also check if the error has the correct error type/message. So other developers will know what we are testing here

}
"#;
let result = serde_json::from_str::<TableMetadata>(metadata);
assert!(result.is_err());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, we should also check if the error has the correct error type/message.

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.

V1 metadata parsing incorrectly accepts snapshots with both manifest-list and manifests.

2 participants