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

Runfiles::create() throws error when parse_repo_mapping returns an error, instead of returning a default RepoMapping #2868

Closed
felipeamp opened this issue Sep 13, 2024 · 5 comments · Fixed by #2883
Labels

Comments

@felipeamp
Copy link
Contributor

Before #2847 was merged Runfiles::create() always called RepoMapping::new() when the Result of parse_repo_mapping was an error. Now, due to the question mark operator after the transpose()

let repo_mapping = raw_rlocation(&mode, "_repo_mapping")
.map(parse_repo_mapping)
.transpose()?
.unwrap_or_default();

the error is returned to the caller, instead of returning a default RepoMapping as before that PR.

@felipeamp felipeamp changed the title Runfiles::create() throws error when parse_repo_mapping returns an error, instead of returning a default RepoMapping Runfiles::create() throws error when parse_repo_mapping returns an error, instead of returning a default RepoMapping Sep 13, 2024
@UebelAndre UebelAndre added the bug label Sep 13, 2024
@UebelAndre
Copy link
Collaborator

Why is parse_repo_mapping returning an error? Is there a bug in how we parse it?

@felipeamp
Copy link
Contributor Author

I'm still trying to figure that one out, and it could be to some local patch I'm carrying. I've asked some other folks to help, but since it's (almost) the weekend I guess it will take a while. I'll let you know if we progress on this.

All I know so far: the error I got was a RepoMappingIoError, thrown when reading the file into a string, and the file was obtained (I believe) in a DirectoryBased mode.

@UebelAndre
Copy link
Collaborator

I started adding some tests here: #2869

The change to make this non-fatal would be trivial but I would like to know why parsing failed. I'm not so familiar with the _repo_mapping file but would runfiles lookup lead to incorrect results without it? If so my naive approach would be to have this error so users don't get bad results with no warning.

@felipeamp
Copy link
Contributor Author

felipeamp commented Sep 16, 2024

I've patched the code from my first comment above by

let repo_mapping = match raw_rlocation(&mode, "_repo_mapping").map(parse_repo_mapping) {
            Some(Ok(r)) => r,
            _ => RepoMapping::new(),
        };

and it fixed the issues we were seeing. Whether there is something else broken by the _repo_mapping logic underneath I don't know, but so far I haven't seen any breakages. Also we don't use bzlmod, so can't say anything about the state of that.

@jblebrun
Copy link

We are also encountering this error in a project. We use Bazel 6, without bzlmod, and I think the issue is that the file just doesn't exist? The RepoMappingIoError we see is always with the message "No such file or directory".

There's similar behavior when trying to use the rust-analyzer gen_rust_project rule. WIth the rules_rust version we currently use (0.48.0), after running gen_rust_project the last message emitted is "No repo mapping!"

With the latest tagged release (0.50.1), there's now a failure with the RepoMappingIoError (also with "No such file or directory").

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 a pull request may close this issue.

3 participants