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

Core: Fix SnapshotProducer#targetBranch's exception message #7315

Merged
merged 4 commits into from
Apr 12, 2023

Conversation

zhongyujiang
Copy link
Contributor

No description provided.

@github-actions github-actions bot added the core label Apr 10, 2023
Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

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

This is a great catch @zhongyujiang the fix looks good to me. can we add a unit test for this? This bug implies this precondition check is not tested so it would be good to have coverage though.

.as("Invalid branch")
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining(
"some-tag is a tag, not a branch. Tags cannot be targets for producing snapshots");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@amogh-jahagirdar These two unit tests already test the precondition check, but the exception msg is not validated, so I updated them.

Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the contribution @zhongyujiang !

Copy link
Contributor

@nastra nastra left a comment

Choose a reason for hiding this comment

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

LGTM once the nits have been applied

() -> table.newFastAppend().appendFile(FILE_A).toBranch("some-tag").commit())
.as("Invalid branch")
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: hasMessage would be better here, since we can match the full error msg

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Assertions.assertThatThrownBy(() -> table.newFastAppend().appendFile(FILE_A).toBranch(null))
.as("Invalid branch")
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Invalid branch name: null");
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: hasMessage would be better here, since we can match the full error msg

@szehon-ho szehon-ho merged commit e7df8c1 into apache:master Apr 12, 2023
30 checks passed
@szehon-ho
Copy link
Collaborator

Merged, thanks @zhongyujiang , and @amogh-jahagirdar , @nastra for reviews

@zhongyujiang zhongyujiang deleted the fix-branch-exception-msg branch April 13, 2023 05:53
manisin pushed a commit to Snowflake-Labs/iceberg that referenced this pull request May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants