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 regression in unmatched globs error message #10595

Merged
merged 1 commit into from Aug 12, 2020

Conversation

Eric-Arellano
Copy link
Contributor

@Eric-Arellano Eric-Arellano commented Aug 12, 2020

Fixes #10574. We were calling throw(&format("{:?}")) on an error that was already had type Failure, meaning that we were converting a Failure to a String, then back to a Failure, which resulted in an overly chatty error message.

Before:

 Exception: Throw { val: Unmatched glob from file arguments: "fake", python_traceback: "Traceback (no traceback):\n  <pants native internals>\nException: Unmatched glob from file arguments: \"fake\"", engine_traceback: ["Snapshotting: PathGlobs(globs=(\'fake\',), glob_match_error_behavior=<GlobMatchErrorBehavior.error: \'error\'>, conjunction=<GlobExpansionConjunction.all_match: \'all_match\'>, description_of_origin=\'file arguments\')"] }

After:

Unmatched glob from file arguments: "fake"

[ci skip-build-wheels]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@cosmicexplorer
Copy link
Contributor

Could I ask you to provide an example of the error message before and after in the description?

Comment on lines -216 to +217
let input_digest = lift_digest(&externs::project_ignoring_type(&args[0], "digest"))?;
let input_digest =
lift_digest(&externs::project_ignoring_type(&args[0], "digest")).map_err(|e| throw(&e))?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that this change and most others are not necessary. The only thing we need is the fix for download_file_to_digest and path_globs_to_digest.

But, personally, I think I find this refactor easier to follow and that it has less coercion of types, like no let Result<_, String>. Still, let me know if this is actually an improvement or I should revert to the old.

Copy link
Contributor

Choose a reason for hiding this comment

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

The one concern I have about this hunk is that it seems to add two throw() conversions where there were none before. Is it possible to keep those as string errors and then re-use the .map_err() at the bottom? Or is the point of this part that you have to add those two throw()s in order to remove the let res statement?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think removing the let res is clearer regardless, so I'm fine if we make this tradeoff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is only part of the refactor. The end effect should be the same, so it's only a question of what's clearer here.

I added comments on the two code blocks that are the actual fixes. Everything else can be reverted if preferred.

Pardon that I didn't make that clearer from the start, and thank you for the prompt feedback :)

@Eric-Arellano
Copy link
Contributor Author

@cosmicexplorer yes, I updated the PR description.

Copy link
Contributor

@cosmicexplorer cosmicexplorer left a comment

Choose a reason for hiding this comment

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

Thanks for adding the message output! Will accept if you can confirm that is where the actual fix is.

Comment on lines -216 to +217
let input_digest = lift_digest(&externs::project_ignoring_type(&args[0], "digest"))?;
let input_digest =
lift_digest(&externs::project_ignoring_type(&args[0], "digest")).map_err(|e| throw(&e))?;
Copy link
Contributor

Choose a reason for hiding this comment

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

The one concern I have about this hunk is that it seems to add two throw() conversions where there were none before. Is it possible to keep those as string errors and then re-use the .map_err() at the bottom? Or is the point of this part that you have to add those two throw()s in order to remove the let res statement?

Comment on lines -216 to +217
let input_digest = lift_digest(&externs::project_ignoring_type(&args[0], "digest"))?;
let input_digest =
lift_digest(&externs::project_ignoring_type(&args[0], "digest")).map_err(|e| throw(&e))?;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think removing the let res is clearer regardless, so I'm fine if we make this tradeoff.

let digest = store.merge(digests).await.map_err(|e| format!("{:?}", e))?;
let res: Result<_, String> = Ok(Snapshot::store_directory(&context.core, &digest));
res
let digests = future::try_join_all(digests).await.map_err(|e| throw(&e))?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the part that fixes it (because we don't call format!() on the inside and then throw() on the outside)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, only a refactor.

Comment on lines 284 to 290
async move {
let key = externs::acquire_key_for(args.pop().unwrap()).map_err(|e| format!("{:?}", e))?;
let snapshot = context
.get(DownloadedFile(key))
.await
.map_err(|e| format!("{:?}", e))?;
let res: Result<_, String> = Ok(Snapshot::store_directory(&core, &snapshot.digest));
res
let key = externs::acquire_key_for(args.pop().unwrap())?;
let snapshot = context.get(DownloadedFile(key)).await?;
Ok(Snapshot::store_directory(&core, &snapshot.digest))
}
.map_err(|err: String| throw(&err))
.boxed()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actual fix for DownloadFile.

Comment on lines -307 to -315
let key = externs::acquire_key_for(args.pop().unwrap()).map_err(|e| format!("{:?}", e))?;
let digest = context
.get(Snapshot(key))
.await
.map_err(|e| format!("{:?}", e))?;
let res: Result<_, String> = Ok(Snapshot::store_directory(&core, &digest));
res
let key = externs::acquire_key_for(args.pop().unwrap())?;
let digest = context.get(Snapshot(key)).await?;
Ok(Snapshot::store_directory(&core, &digest))
}
.map_err(|err: String| throw(&err))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actual fix for PathGlobs.

let digest = store.merge(digests).await.map_err(|e| format!("{:?}", e))?;
let res: Result<_, String> = Ok(Snapshot::store_directory(&context.core, &digest));
res
let digests = future::try_join_all(digests).await.map_err(|e| throw(&e))?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, only a refactor.

Comment on lines -216 to +217
let input_digest = lift_digest(&externs::project_ignoring_type(&args[0], "digest"))?;
let input_digest =
lift_digest(&externs::project_ignoring_type(&args[0], "digest")).map_err(|e| throw(&e))?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is only part of the refactor. The end effect should be the same, so it's only a question of what's clearer here.

I added comments on the two code blocks that are the actual fixes. Everything else can be reverted if preferred.

Pardon that I didn't make that clearer from the start, and thank you for the prompt feedback :)

Copy link
Contributor

@cosmicexplorer cosmicexplorer left a comment

Choose a reason for hiding this comment

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

Thank you so much! Didn't realize there were two separate fixes :D

@coveralls
Copy link

Coverage Status

Coverage remained the same at 0.0% when pulling 9a3a5fa on Eric-Arellano:fix-glob-error into b10cca1 on pantsbuild:master.

@Eric-Arellano Eric-Arellano merged commit bb9b53c into pantsbuild:master Aug 12, 2020
@Eric-Arellano Eric-Arellano deleted the fix-glob-error branch August 12, 2020 16:02
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.

Regression in "unmatched glob" error
3 participants