From 93b62e41496886c6a69445f066f3f1b6ed3fcb6a Mon Sep 17 00:00:00 2001 From: Robert-Jan Huijsman <22160949+rjhuijsman@users.noreply.github.com> Date: Fri, 13 Feb 2026 13:10:25 +0000 Subject: [PATCH 1/2] bazel: handle generated protos from external repos When pyprotoc is used through an external repository, generated proto files can arrive with a path/short_path mismatch: - path: bazel-out/.../external//... - short_path: ..//... The previous logic in `rules.bzl` did not match this shape and fell through to "Handling this type of (generated?) .proto file was not forseen". This commit adds a narrow branch in the existing proto loop to normalize this short_path form to a repo-relative path and emit the corresponding `-I` + input proto args. This keeps existing behavior for local files, external source files, and `_virtual_imports`, while fixing generated protos from external repos. --- rules.bzl | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/rules.bzl b/rules.bzl index e3cde4a..d8cc2da 100644 --- a/rules.bzl +++ b/rules.bzl @@ -101,6 +101,35 @@ def _protoc_plugin_rule_implementation(context): proto_files = unique_proto_files for proto_file in proto_files: + # If Bazel gives us a `_virtual_imports` path, that path is already the + # canonical import view for `protoc` (import root + import-relative + # filename). We must use it as-is and skip all other path handling. + # + # Important: do not fall through to local/external logic for these + # files. That logic computes a different `-I` root from physical paths, + # which can disagree with the virtual import view and break imports. + # Local/external branches below are only for non-virtual paths. + if _virtual_imports in proto_file.path: + before, after = proto_file.path.split(_virtual_imports) + import_path = before + _virtual_imports + after.split("/")[0] + "/" + args += [ + "-I" + import_path, + proto_file.path.replace(import_path, ""), + ] + continue + + # Handle generated files in external repositories where Bazel surfaces + # short paths like "..//.proto". + if proto_file.short_path.startswith("../"): + short_path = proto_file.short_path.removeprefix("../") + if "/" in short_path: + short_path = short_path.split("/", 1)[1] + if proto_file.path.endswith(short_path): + import_path = proto_file.path[:-len(short_path)] + args.append("-I" + import_path) + args.append(short_path) + continue + if len(proto_file.owner.workspace_root) == 0: # Handle case where `proto_file` is a local file. # This includes both source files in the workspace and files @@ -109,7 +138,6 @@ def _protoc_plugin_rule_implementation(context): # determine the import path correctly for that case. For # files which are part of the workspace, the `import_path` # will be empty and we will set it to `./`. - elements = proto_file.path.split("/") import_path = proto_file.path[:-len(proto_file.short_path)] if import_path == "": @@ -130,15 +158,6 @@ def _protoc_plugin_rule_implementation(context): "-I" + import_path, proto_file.path.replace(import_path, ""), ] - elif _virtual_imports in proto_file.path: - # Handle case where `proto_file` is a generated file file in - # `_virtual_imports`. - before, after = proto_file.path.split(_virtual_imports) - import_path = before + _virtual_imports + after.split("/")[0] + "/" - args += [ - "-I" + import_path, - proto_file.path.replace(import_path, ""), - ] else: fail( "Handling this type of (generated?) .proto file " + From fc15160b7c33e55540332780c39194248fb2f01e Mon Sep 17 00:00:00 2001 From: Robert-Jan Huijsman <22160949+rjhuijsman@users.noreply.github.com> Date: Fri, 13 Feb 2026 14:46:29 +0000 Subject: [PATCH 2/2] Re-add `.mergequeue/config.ml` post UI-based fix Now that we've been able to use the UI to remove the stale check-requirements, we can reintroduce the file-based config. --- .mergequeue/config.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .mergequeue/config.yml diff --git a/.mergequeue/config.yml b/.mergequeue/config.yml new file mode 100644 index 0000000..357033b --- /dev/null +++ b/.mergequeue/config.yml @@ -0,0 +1,32 @@ +version: 1.0.0 +merge_rules: + labels: + trigger: mergequeue-ready + skip_line: "" + merge_failed: "" + skip_delete_branch: "" + update_latest: true + delete_branch: false + use_rebase: true + enable_comments: true + ci_timeout_mins: 0 + preconditions: + number_of_approvals: 1 + required_checks: [] + use_github_mergeability: false + conversation_resolution_required: true + merge_mode: + type: default + parallel_mode: null + auto_update: + enabled: false + label: "" + max_runs_for_update: 0 + merge_commit: + use_title_and_body: false + merge_strategy: + name: squash + override_labels: + squash: "" + merge: "" + rebase: mergequeue-rebase