Skip to content

Add bazel query options setting #556

Open
markkohdev wants to merge 3 commits into
bazel-contrib:masterfrom
markkohdev:markkoh/query-options
Open

Add bazel query options setting #556
markkohdev wants to merge 3 commits into
bazel-contrib:masterfrom
markkohdev:markkoh/query-options

Conversation

@markkohdev

@markkohdev markkohdev commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

Description

For very large bazel repos, git sparse checkout is commonly used to only pull a subset of directories in a repo. When this happens, the local version of the repo may not have all of the dependencies of all packages or tools required and this is expected.

Because the current bazel query call on extension startup passes ...:* as the default query, the extension will automatically try to query all packages and will fail if any are missing, and will infinitely re-query and fail. This can be resolved by adding --keep_going to the query command.

This PR adds a bazel query packages options setting to allow users to append custom parameters to the bazel query to support things such as sparse checkout.

Related Issue

#198

Testing

  • Tests added/updated
  • Manual testing performed

Checklist

  • Code follows the project's style guidelines (prettier/eslint)
  • Commit messages follow Conventional Commit conventions
  • Tests pass locally (npm run test)

@markkohdev markkohdev force-pushed the markkoh/query-options branch 3 times, most recently from b9cfd69 to 4d80964 Compare January 28, 2026 22:14
Comment thread src/bazel/bazel_query.ts
abortSignal?: AbortSignal;
} = {},
): Promise<blaze_query.QueryResult> {
const bazelConfig = vscode.workspace.getConfiguration("bazel");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Once #552 is merged, please adapt and move to configuration.ts

@cbandera cbandera left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wonder whether we shouldn't set the --keep_going flag by default, in order to be robust against temporary changes.
I.e. I keep seeing errors when I save my build file with partial changes and my build tree hence becomes temporarily corrupt....

@markkohdev markkohdev force-pushed the markkoh/query-options branch 3 times, most recently from 54d4821 to 0c83368 Compare February 9, 2026 15:58
@markkohdev markkohdev force-pushed the markkoh/query-options branch from 0c83368 to cb07a4b Compare February 9, 2026 15:59
@markkohdev

Copy link
Copy Markdown
Contributor Author

I wonder whether we shouldn't set the --keep_going flag by default, in order to be robust against temporary changes. I.e. I keep seeing errors when I save my build file with partial changes and my build tree hence becomes temporarily corrupt....

@cbandera that might not be a bad idea tbh. I think that the custom query options setting is still helpful, but perhaps it would be better if we basically just encode --keep_going as it's own setting. e.g:

                "bazel.ignorePackageFailures": {
                    "type": "boolean",
                    "default": true,
                    "markdownDescription": "Whether to ignore failures in packages query (passes `--keep_going` to query command)."
                },

The only caveat is that if there are errors in the query output that result in the query not resolving the users' package, then users might be confused as to why their packages aren't showing up.
Perhaps we could parse the stdout and capture the packages that have errors as orange or red in the build tree panel?

@markkohdev markkohdev force-pushed the markkoh/query-options branch from 480dcf0 to d3532ec Compare February 9, 2026 17:37
@markkohdev markkohdev marked this pull request as ready for review February 9, 2026 17:37
@markkohdev markkohdev closed this Feb 9, 2026
@markkohdev markkohdev reopened this Feb 9, 2026
@markkohdev

Copy link
Copy Markdown
Contributor Author

@cbandera thoughts on my last comment and changes?

@cbandera

Copy link
Copy Markdown
Collaborator

If the scope of the problem that you are facing in your setup is really "just" the querying for packages (which is only used for the workspace-tree) then I would prefer to simply pass --keep_going for this specific query by default.
With the new logger we do have the possibility to point the user to more information in the log output.

Adding too many configuration options for the users that most of the devs wont ever use, just clutters the settings and makes it harder to use.

I would also vote against coloring the workspace tree - that's too much added complexity.

@cameron-martin do you have any thoughts on this PRs proposal?

@cameron-martin

Copy link
Copy Markdown
Collaborator

I agree that always passing --keep_going sounds reasonable instead of adding another option.

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.

3 participants