Skip to content

Commit 0957535

Browse files
authored
chore(librarian): fix proto_library/py_test not found error (#14631)
This PR resolves the following stack traces which appear in the last `librarian generate` job ``` Traceback (most recent call last): File "/app/./cli.py", line 532, in handle_generate _generate_api(api_path, library_id, source, output, version) File "/app/./cli.py", line 764, in _generate_api py_gapic_config = _read_bazel_build_py_rule(api_path, source) File "/app/./cli.py", line 556, in _read_bazel_build_py_rule result = parse_googleapis_content.parse_content(content) File "/app/parse_googleapis_content.py", line 149, in parse_content sl.eval(mod, ast, glb, sl.FileLoader(load)) starlark.StarlarkError: error: Variable `proto_library` not found --> BUILD.bazel:28:1 | 28 | proto_library( | ^^^^^^^^^^^^^ | The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/./cli.py", line 1412, in <module> args.func( File "/app/./cli.py", line 538, in handle_generate raise ValueError("Generation failed.") from e ValueError: Generation failed. time=2025-10-02T11:28:44.666Z level=INFO msg="=== Docker end =================================================================" time=2025-10-02T11:28:44.667Z level=ERROR msg="failed to generate library" id=google-cloud-source-context err="exit status 1" ``` ``` Traceback (most recent call last): File "/app/./cli.py", line 532, in handle_generate _generate_api(api_path, library_id, source, output, version) File "/app/./cli.py", line 764, in _generate_api py_gapic_config = _read_bazel_build_py_rule(api_path, source) File "/app/./cli.py", line 556, in _read_bazel_build_py_rule result = parse_googleapis_content.parse_content(content) File "/app/parse_googleapis_content.py", line 149, in parse_content sl.eval(mod, ast, glb, sl.FileLoader(load)) starlark.StarlarkError: error: Variable `py_test` not found --> BUILD.bazel:188:1 | 188 | py_test( | ^^^^^^^ | The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/./cli.py", line 1412, in <module> args.func( File "/app/./cli.py", line 538, in handle_generate raise ValueError("Generation failed.") from e ValueError: Generation failed. time=2025-10-02T12:32:33.921Z level=INFO msg="=== Docker end =================================================================" time=2025-10-02T12:32:33.921Z level=ERROR msg="failed to generate library" id=google-cloud-recommendations-ai err="exit status 1" ```
1 parent 12790db commit 0957535

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

.generator/parse_googleapis_content.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@
9090
_NOOP_CALLABLES = (
9191
"package",
9292
"alias",
93-
"py_test",
9493
"sh_binary",
95-
"proto_library",
9694
"java_proto_library",
9795
"genrule",
9896
"gapic_yaml_from_disco",
@@ -130,6 +128,8 @@ def fake_glob(paths=[], **args):
130128
return []
131129

132130
mod.add_callable("package", noop_bazel_rule)
131+
mod.add_callable("proto_library", noop_bazel_rule)
132+
mod.add_callable("py_test", noop_bazel_rule)
133133

134134
for glob_callable in _GLOB_CALLABLES:
135135
mod.add_callable(glob_callable, fake_glob)

0 commit comments

Comments
 (0)