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

Querying "//..." fails if a top-level target exists and any external dependency can't be fetched #12497

Closed
jmillikin-stripe opened this issue Nov 17, 2020 · 1 comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Performance Issues for Performance teams type: bug

Comments

@jmillikin-stripe
Copy link
Contributor

Description of the problem / feature request:

If a workspace contains an external dependency that can't be fetched (upstream 404, shasum mismatch, whatever) then the presence of a build target in the top-level package will cause bazel query on //... to fail.

This happens regardless of whether the external dependency is in the transitive closure of the top-level target. As long as there is any top-level target, and in the workspace there is any target depending on the broken external dependency, then the query fails.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Given the following workspace:

# WORKSPACE
workspace(name = "bazeltest_query_toplevel")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "example_com_noexist",
    urls = ["https://example.com/noexist.tar.gz"],
    sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
)
# BUILD
genrule(
    name = "gen_toplevel",
    outs = ["gen_toplevel.txt"],
    cmd = "touch $@",
)
# subpkg/BUILD
genrule(
    name = "gen_subpkg",
    srcs = ["@example_com_noexist//:noexist.txt"],
    outs = ["gen_subpkg.txt"],
    cmd = "touch $@",
)

bazel query fails:

$ bazel query 'kind("my_query_target", //...)'
[...]
Error in download_and_extract: java.io.IOException: Error downloading [https://example.com/noexist.tar.gz] to /private/var/tmp/_bazel_jmillikin/1d615cc9026acc39a3353897884f7725/external/example_com_noexist/temp2794112296295295544/noexist.tar.gz: GET returned 404 Not Found
ERROR: Evaluation of query "kind('my_query_target', //...)" failed due to BUILD file errors
Loading: 2 packages loaded

Removing the gen_toplevel target -- which has no relation to the failing dependency -- fixes the error, and lets bazel query successfully return an empty result set:

$ cat BUILD 
#genrule(
#    name = "gen_toplevel",
#    outs = ["gen_toplevel.txt"],
#    cmd = "touch $@",
#)
$ bazel query 'kind("my_query_target", //...)'
INFO: Empty results
Loading: 1 packages loaded
$

What operating system are you running Bazel on?

macOS, but I believe this bug is not platform-specific.

What's the output of bazel info release?

Successfully reproduced with:

  • release 3.7.0
  • release 3.4.1

I have not yet tried reproducing at HEAD, or with an older release.

@oquenchil oquenchil added team-Performance Issues for Performance teams untriaged type: bug labels Nov 18, 2020
@meisterT meisterT added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Nov 19, 2020
@meisterT
Copy link
Member

Interesting find. cc @zhengwei143 @Wyverald

benjaminp added a commit to benjaminp/bazel that referenced this issue Dec 1, 2020
…al workspaces.

A packages path fragment is not unambiguous when external workspaces are involved.

Fixes bazelbuild#12497.
benjaminp added a commit to benjaminp/bazel that referenced this issue Dec 1, 2020
…al workspaces.

A package's path fragment is not unambiguous when external workspaces are involved.

Fixes bazelbuild#12497.
benjaminp added a commit to benjaminp/bazel that referenced this issue Dec 4, 2020
…al workspaces.

A package's path fragment is not unambiguous when external workspaces are involved.

Fixes bazelbuild#12497.
benjaminp added a commit to benjaminp/bazel that referenced this issue Dec 4, 2020
…al workspaces.

A package's path fragment is not unambiguous when external workspaces are involved.

Fixes bazelbuild#12497.
philwo pushed a commit that referenced this issue Dec 7, 2020
…al workspaces.

A package's path fragment is not unambiguous when external workspaces are involved.

Fixes #12497.

Closes #12595.

PiperOrigin-RevId: 346048937
philwo pushed a commit that referenced this issue Dec 7, 2020
…al workspaces.

A package's path fragment is not unambiguous when external workspaces are involved.

Fixes #12497.

Closes #12595.

PiperOrigin-RevId: 346048937
philwo pushed a commit that referenced this issue Dec 9, 2020
…al workspaces.

A package's path fragment is not unambiguous when external workspaces are involved.

Fixes #12497.

Closes #12595.

PiperOrigin-RevId: 346048937
philwo pushed a commit that referenced this issue Dec 10, 2020
…al workspaces.

A package's path fragment is not unambiguous when external workspaces are involved.

Fixes #12497.

Closes #12595.

PiperOrigin-RevId: 346048937
ulfjack pushed a commit to EngFlow/bazel that referenced this issue Mar 5, 2021
…al workspaces.

A package's path fragment is not unambiguous when external workspaces are involved.

Fixes bazelbuild#12497.

Closes bazelbuild#12595.

PiperOrigin-RevId: 346048937
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Performance Issues for Performance teams type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants