Skip to content

Commit 88db83f

Browse files
authored
chore(librarian): fix generation for google-cloud-common (#14611)
This fixes the following stack trace with generation for `google-cloud-common` which caused generation to fail ``` 2025-10-01 16:23:35,628 synthtool [WARNING] > No replacements made in packages/google-cloud-common/docs/index.rst for pattern API Reference ------------- .. toctree:: :maxdepth: 2 common/services_ common/types_ , maybe replacement is no longer needed? 2025-10-01 16:23:35,628 synthtool [WARNING] > No replacements made in packages/google-cloud-common/docs/index.rst for pattern API Reference ------------- .. toctree:: :maxdepth: 2 common/services_ common/types_ , maybe replacement is no longer needed? README.rst Skipping: docs/index.rst docs/summary_overview.md Traceback (most recent call last): File "/app/./cli.py", line 535, in handle_generate _run_post_processor(output, library_id) File "/app/./cli.py", line 300, in _run_post_processor python_mono_repo.owlbot_main(path_to_library) File "/usr/local/lib/python3.9/site-packages/synthtool/languages/python_mono_repo.py", line 329, in owlbot_main apply_client_specific_post_processing( File "/usr/local/lib/python3.9/site-packages/synthtool/languages/python_mono_repo.py", line 213, in apply_client_specific_post_processing assert ( AssertionError: Replaced 0 rather than 1 instances The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/./cli.py", line 1406, in <module> args.func( File "/app/./cli.py", line 538, in handle_generate raise ValueError("Generation failed.") from e ValueError: Generation failed. ```
1 parent de1cf08 commit 88db83f

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

.generator/cli.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,9 +694,12 @@ def _get_staging_child_directory(api_path: str, is_proto_only_library: bool) ->
694694
version_candidate = api_path.split("/")[-1]
695695
if version_candidate.startswith("v") and not is_proto_only_library:
696696
return version_candidate
697-
else:
698-
# Fallback for non-'v' version segment
697+
elif is_proto_only_library:
698+
# Fallback for non-'v' version segment for proto-only library
699699
return f"{os.path.basename(api_path)}-py/{api_path}"
700+
else:
701+
# Fallback for non-'v' version segment for GAPIC
702+
return f"{os.path.basename(api_path)}-py"
700703

701704

702705
def _stage_proto_only_library(

.generator/test_cli.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ def test_verify_library_namespace_error_no_gapic_file(mocker, mock_path_class):
13571357
mock_path_class.assert_called_once_with("repo/packages/my-lib")
13581358

13591359

1360-
def test_get_staging_child_directory_gapic():
1360+
def test_get_staging_child_directory_gapic_versioned():
13611361
"""
13621362
Tests the behavior for GAPIC clients with standard 'v' prefix versioning.
13631363
Should return only the version segment (e.g., 'v1').
@@ -1367,6 +1367,15 @@ def test_get_staging_child_directory_gapic():
13671367
expected = "v1"
13681368
assert _get_staging_child_directory(api_path, False) == expected
13691369

1370+
def test_get_staging_child_directory_gapic_non_versioned():
1371+
"""
1372+
Tests the behavior for GAPIC clients with no standard 'v' prefix versioning.
1373+
Should return library-py
1374+
"""
1375+
api_path = "google/cloud/language"
1376+
expected = "language-py"
1377+
assert _get_staging_child_directory(api_path, False) == expected
1378+
13701379

13711380
def test_get_staging_child_directory_proto_only():
13721381
"""

.librarian/state.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,7 @@ libraries:
15691569
- scripts/client-post-processing
15701570
- samples/snippets/README.rst
15711571
- tests/system
1572+
- tests/unit/gapic/common/test_common.py
15721573
remove_regex:
15731574
- packages/google-cloud-common
15741575
tag_format: '{id}-v{version}'

0 commit comments

Comments
 (0)