Skip to content

chore(migration): Migrate code from googleapis/python-api-core into packages/google-api-core#15567

Merged
parthea merged 579 commits intomainfrom
migration.python-api-core.migration.2026-02-13_19-20-54.migrate
Feb 17, 2026
Merged

chore(migration): Migrate code from googleapis/python-api-core into packages/google-api-core#15567
parthea merged 579 commits intomainfrom
migration.python-api-core.migration.2026-02-13_19-20-54.migrate

Conversation

@parthea
Copy link
Copy Markdown
Contributor

@parthea parthea commented Feb 13, 2026

See #10892.

This PR should be merged with a merge-commit, not a squash-commit, in order to preserve the git history.

hugovk and others added 30 commits March 5, 2022 11:37
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
The operation wrapped by ExtendedOperation may define other fields or methods
that the user may wish to use.
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* chore(python): use black==22.3.0

Source-Link: googleapis/synthtool@6fab84a
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe

* ci: use black 22.3.0

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
)

Source-Link: googleapis/synthtool@7804ade
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:eede5672562a32821444a8e803fb984a6f61f2237ea3de229d2de24453f4ae7d
Source-Link: googleapis/synthtool@06e8279
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:b3500c053313dc34e07b1632ba9e4e589f4f77036a7cf39e1fe8906811ae0fce

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@eb78c98
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* chore(deps): update all dependencies

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@f15cc72
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bc5eed3804aec2f05fad42aacf973821d9500c174015341f721a984a0825b6fd
* test: use == instead of is when comparing equality

* use not instead of ==
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
…374)

Source-Link: googleapis/synthtool@6b4d5a6
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:f792ee1320e03eda2d13a5281a2989f7ed8a9e50b73ef6da97fac7e1e850b149

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@453a5d9
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:81ed5ecdfc7cac5b699ba4537376f3563f6f04122c4ec9e735d3b3dc1d43dd32
feat: adds support for audience in client_options.
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Also adds upper limits for extras.

fix(deps): require googleapis-common-protos >= 1.56.2
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* chore: allow releases from older version branches

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
`UNAVAILABLE` instead of `UNVAILABLE`

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-api-core/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [ ] Ensure the tests and linter pass
- [ ] Code coverage does not decrease (if any source code was changed)
- [ ] Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕
* chore: test minimum dependencies in python 3.7

* remove duplicate entry
vchudnov-g and others added 7 commits February 4, 2026 14:48
This fix removes the `nox.options.sessions` that were left in the
noxfile when those sessions were removed in #873.
Require Python 3.9+
Require protobuf 4.25.8+
Simplify code accordingly.

Fixes #15019 

This also required removing 3.7 and 3.8 as required checks in the repo
config, under branch protection rules.
… into migration.python-api-core.migration.2026-02-13_19-20-54.migrate
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @parthea, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request executes a significant structural migration of the google-api-core Python library. The core objective is to relocate the entire codebase, its associated documentation, configuration, and testing infrastructure into a new, dedicated packages/google-api-core directory. This change is purely organizational, aiming to improve repository structure and management without altering any existing functionality or introducing new features. It ensures that all components of the library are consolidated under a single, well-defined package path.

Highlights

  • Codebase Relocation: The entire google-api-core library, including all Python modules, is moved into packages/google-api-core.
  • Documentation Migration: All Sphinx documentation source files and static assets are relocated to packages/google-api-core/docs.
  • Configuration Files: Project configuration files such as .coveragerc, .flake8, .gitignore, .pre-commit-config.yaml, pyproject.toml, and renovate.json are moved to the new package directory.
  • Changelog and Metadata: The CHANGELOG.md, CODE_OF_CONDUCT.md, CONTRIBUTING.rst, LICENSE, MANIFEST.in, README.rst, SECURITY.md, and .repo-metadata.json files are now located within packages/google-api-core.
  • Test Suite Relocation: All unit and asyncio tests, along with testing constraints, are moved to packages/google-api-core/tests and packages/google-api-core/testing.
  • Script Relocation: Utility scripts for README generation and secret decryption are moved to packages/google-api-core/scripts.
Changelog
  • packages/google-api-core/.coveragerc
    • Added code coverage configuration.
  • packages/google-api-core/.flake8
    • Added flake8 linting configuration.
  • packages/google-api-core/.gitignore
    • Added Git ignore patterns.
  • packages/google-api-core/.librarian/state.yaml
    • Added librarian tool state configuration.
  • packages/google-api-core/.pre-commit-config.yaml
    • Added pre-commit hook configuration.
  • packages/google-api-core/.repo-metadata.json
    • Added repository metadata.
  • packages/google-api-core/CHANGELOG.md
    • Added historical changelog entries.
  • packages/google-api-core/CODE_OF_CONDUCT.md
    • Added project Code of Conduct.
  • packages/google-api-core/CONTRIBUTING.rst
    • Added contribution guidelines.
  • packages/google-api-core/LICENSE
    • Added Apache 2.0 license.
  • packages/google-api-core/MANIFEST.in
    • Added distribution manifest.
  • packages/google-api-core/README.rst
    • Added project README.
  • packages/google-api-core/SECURITY.md
    • Added security policy.
  • packages/google-api-core/docs/_static/custom.css
    • Added custom documentation CSS.
  • packages/google-api-core/docs/_templates/layout.html
    • Added custom documentation layout.
  • packages/google-api-core/docs/auth.rst
    • Added authentication documentation.
  • packages/google-api-core/docs/client_info.rst
    • Added client information documentation.
  • packages/google-api-core/docs/client_options.rst
    • Added client options documentation.
  • packages/google-api-core/docs/conf.py
    • Added Sphinx documentation configuration.
  • packages/google-api-core/docs/exceptions.rst
    • Added exceptions documentation.
  • packages/google-api-core/docs/futures.rst
    • Added futures documentation.
  • packages/google-api-core/docs/helpers.rst
    • Added helpers documentation.
  • packages/google-api-core/docs/iam.rst
    • Added IAM documentation.
  • packages/google-api-core/docs/index.rst
    • Added documentation index.
  • packages/google-api-core/docs/multiprocessing.rst
    • Added multiprocessing documentation.
  • packages/google-api-core/docs/operation.rst
    • Added long-running operations documentation.
  • packages/google-api-core/docs/operations_client.rst
    • Added operations client documentation.
  • packages/google-api-core/docs/page_iterator.rst
    • Added page iterators documentation.
  • packages/google-api-core/docs/path_template.rst
    • Added path templates documentation.
  • packages/google-api-core/docs/retry.rst
    • Added retry documentation.
  • packages/google-api-core/docs/timeout.rst
    • Added timeout documentation.
  • packages/google-api-core/google/api_core/init.py
    • Added package initialization.
  • packages/google-api-core/google/api_core/_python_package_support.py
    • Added Python package support utilities.
  • packages/google-api-core/google/api_core/_python_version_support.py
    • Added Python version support utilities.
  • packages/google-api-core/google/api_core/_rest_streaming_base.py
    • Added base class for REST streaming.
  • packages/google-api-core/google/api_core/bidi.py
    • Added synchronous bidirectional streaming helpers.
  • packages/google-api-core/google/api_core/bidi_async.py
    • Added asynchronous bidirectional streaming helpers.
  • packages/google-api-core/google/api_core/bidi_base.py
    • Added base class for bidirectional streaming.
  • packages/google-api-core/google/api_core/client_info.py
    • Added client information utilities.
  • packages/google-api-core/google/api_core/client_logging.py
    • Added client logging utilities.
  • packages/google-api-core/google/api_core/client_options.py
    • Added client options class.
  • packages/google-api-core/google/api_core/datetime_helpers.py
    • Added datetime helper functions.
  • packages/google-api-core/google/api_core/exceptions.py
    • Added custom exception classes.
  • packages/google-api-core/google/api_core/extended_operation.py
    • Added extended operation futures.
  • packages/google-api-core/google/api_core/future/init.py
    • Added futures package initialization.
  • packages/google-api-core/google/api_core/future/_helpers.py
    • Added private future helpers.
  • packages/google-api-core/google/api_core/future/async_future.py
    • Added asynchronous future implementation.
  • packages/google-api-core/google/api_core/future/base.py
    • Added base future classes.
  • packages/google-api-core/google/api_core/future/polling.py
    • Added polling future implementation.
  • packages/google-api-core/google/api_core/gapic_v1/init.py
    • Added GAPIC v1 package initialization.
  • packages/google-api-core/google/api_core/gapic_v1/client_info.py
    • Added GAPIC v1 client information.
  • packages/google-api-core/google/api_core/gapic_v1/config.py
    • Added GAPIC v1 configuration helpers.
  • packages/google-api-core/google/api_core/gapic_v1/config_async.py
    • Added asynchronous GAPIC v1 configuration helpers.
  • packages/google-api-core/google/api_core/gapic_v1/method.py
    • Added GAPIC v1 method wrapping helpers.
  • packages/google-api-core/google/api_core/gapic_v1/method_async.py
    • Added asynchronous GAPIC v1 method wrapping helpers.
  • packages/google-api-core/google/api_core/gapic_v1/routing_header.py
    • Added GAPIC v1 routing header helpers.
  • packages/google-api-core/google/api_core/general_helpers.py
    • Added general helper functions.
  • packages/google-api-core/google/api_core/grpc_helpers.py
    • Added gRPC helper functions.
  • packages/google-api-core/google/api_core/grpc_helpers_async.py
    • Added asynchronous gRPC helper functions.
  • packages/google-api-core/google/api_core/iam.py
    • Added IAM policy definitions.
  • packages/google-api-core/google/api_core/operation.py
    • Added long-running operation futures.
  • packages/google-api-core/google/api_core/operation_async.py
    • Added asynchronous long-running operation futures.
  • packages/google-api-core/google/api_core/operations_v1/init.py
    • Added operations v1 package initialization.
  • packages/google-api-core/google/api_core/operations_v1/abstract_operations_base_client.py
    • Added abstract base client for operations.
  • packages/google-api-core/google/api_core/operations_v1/abstract_operations_client.py
    • Added abstract operations client.
  • packages/google-api-core/google/api_core/operations_v1/operations_async_client.py
    • Added asynchronous operations client.
  • packages/google-api-core/google/api_core/operations_v1/operations_client.py
    • Added operations client.
  • packages/google-api-core/google/api_core/operations_v1/operations_client_config.py
    • Added operations client configuration.
  • packages/google-api-core/google/api_core/operations_v1/operations_rest_client_async.py
    • Added asynchronous REST operations client.
  • packages/google-api-core/google/api_core/operations_v1/pagers.py
    • Added operations pagers.
  • packages/google-api-core/google/api_core/operations_v1/pagers_async.py
    • Added asynchronous operations pagers.
  • packages/google-api-core/google/api_core/operations_v1/pagers_base.py
    • Added base operations pagers.
  • packages/google-api-core/google/api_core/operations_v1/transports/init.py
    • Added operations transports initialization.
  • packages/google-api-core/google/api_core/operations_v1/transports/base.py
    • Added base operations transport.
  • packages/google-api-core/google/api_core/operations_v1/transports/rest.py
    • Added REST operations transport.
  • packages/google-api-core/google/api_core/operations_v1/transports/rest_asyncio.py
    • Added asynchronous REST operations transport.
  • packages/google-api-core/google/api_core/page_iterator.py
    • Added page iterator utilities.
  • packages/google-api-core/google/api_core/page_iterator_async.py
    • Added asynchronous page iterator utilities.
  • packages/google-api-core/google/api_core/path_template.py
    • Added path template utilities.
  • packages/google-api-core/google/api_core/protobuf_helpers.py
    • Added protobuf helper functions.
  • packages/google-api-core/google/api_core/py.typed
    • Added PEP 561 marker file.
  • packages/google-api-core/google/api_core/rest_helpers.py
    • Added REST helper functions.
  • packages/google-api-core/google/api_core/rest_streaming.py
    • Added REST streaming helpers.
  • packages/google-api-core/google/api_core/rest_streaming_async.py
    • Added asynchronous REST streaming helpers.
  • packages/google-api-core/google/api_core/retry/init.py
    • Added retry package initialization.
  • packages/google-api-core/google/api_core/retry/retry_base.py
    • Added base retry classes and functions.
  • packages/google-api-core/google/api_core/retry/retry_streaming.py
    • Added streaming retry wrapper.
  • packages/google-api-core/google/api_core/retry/retry_streaming_async.py
    • Added asynchronous streaming retry wrapper.
  • packages/google-api-core/google/api_core/retry/retry_unary.py
    • Added unary retry helpers.
  • packages/google-api-core/google/api_core/retry/retry_unary_async.py
    • Added asynchronous unary retry helpers.
  • packages/google-api-core/google/api_core/retry_async.py
    • Added asynchronous retry utilities.
  • packages/google-api-core/google/api_core/timeout.py
    • Added timeout decorators.
  • packages/google-api-core/google/api_core/universe.py
    • Added universe domain helpers.
  • packages/google-api-core/google/api_core/version.py
    • Updated package version to 2.29.1.
  • packages/google-api-core/google/api_core/version_header.py
    • Added API version header utilities.
  • packages/google-api-core/noxfile.py
    • Added Nox configuration for testing.
  • packages/google-api-core/pyproject.toml
    • Added project configuration and dependencies.
  • packages/google-api-core/renovate.json
    • Added Renovate configuration.
  • packages/google-api-core/scripts/decrypt-secrets.sh
    • Added script for decrypting secrets.
  • packages/google-api-core/scripts/readme-gen/readme_gen.py
    • Added README generation script.
  • packages/google-api-core/scripts/readme-gen/templates/README.tmpl.rst
    • Added README template.
  • packages/google-api-core/scripts/readme-gen/templates/auth.tmpl.rst
    • Added authentication template.
  • packages/google-api-core/scripts/readme-gen/templates/auth_api_key.tmpl.rst
    • Added API key authentication template.
  • packages/google-api-core/scripts/readme-gen/templates/install_deps.tmpl.rst
    • Added install dependencies template.
  • packages/google-api-core/scripts/readme-gen/templates/install_portaudio.tmpl.rst
    • Added install PortAudio template.
  • packages/google-api-core/setup.py
    • Added setup script.
  • packages/google-api-core/testing/.gitignore
    • Added testing gitignore.
  • packages/google-api-core/testing/constraints-3.9.txt
    • Added Python 3.9 dependency constraints.
  • packages/google-api-core/testing/constraints-async-rest-3.9.txt
    • Added Python 3.9 async REST dependency constraints.
  • packages/google-api-core/tests/asyncio/future/test_async_future.py
    • Added asynchronous future unit tests.
  • packages/google-api-core/tests/asyncio/gapic/test_config_async.py
    • Added asynchronous GAPIC config unit tests.
  • packages/google-api-core/tests/asyncio/gapic/test_method_async.py
    • Added asynchronous GAPIC method unit tests.
  • packages/google-api-core/tests/asyncio/operations_v1/test_operations_async_client.py
    • Added asynchronous operations client unit tests.
  • packages/google-api-core/tests/asyncio/retry/test_retry_streaming_async.py
    • Added asynchronous streaming retry unit tests.
  • packages/google-api-core/tests/asyncio/retry/test_retry_unary_async.py
    • Added asynchronous unary retry unit tests.
  • packages/google-api-core/tests/asyncio/test_bidi_async.py
    • Added asynchronous bidirectional streaming unit tests.
Activity
  • The pull request was created by parthea.
  • The PR description explicitly states that it should be merged with a merge-commit to preserve git history, referencing issue Adopt split repo: _python-api-core_ #10892. This suggests a planned, significant structural change.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@parthea parthea self-assigned this Feb 13, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the google-api-core library into a sub-package structure. The migration appears comprehensive, including source code, tests, CI configurations, and documentation. My review focuses on improving the robustness of time-based logic, enhancing error handling for REST responses, and ensuring adherence to internal rules regarding dictionary serialization. Specifically, I recommend using monotonic time for throttling, handling potential JSON parsing errors in async REST transports, and programmatically sorting log dictionaries before serialization.

Comment on lines +57 to +59
def _process_chunk(self, chunk: str):
if self._level == 0:
if chunk[0] != "[":
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Accessing chunk[0] without checking if the chunk is empty will raise an IndexError. It's safer to ensure the chunk contains data before attempting to validate the start of the JSON array.

    def _process_chunk(self, chunk: str):
        if not chunk:
            return
        if self._level == 0:
            if chunk[0] != "[":

Comment on lines +183 to +199
with self._entry_lock:
cutoff_time = datetime.datetime.now() - self._time_window

# drop the entries that are too old, as they are no longer relevant
while self._past_entries and self._past_entries[0] < cutoff_time:
self._past_entries.popleft()

if len(self._past_entries) < self._access_limit:
self._past_entries.append(datetime.datetime.now())
return 0.0 # no waiting was needed

to_wait = (self._past_entries[0] - cutoff_time).total_seconds()
time.sleep(to_wait)

self._past_entries.append(datetime.datetime.now())
return to_wait

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using datetime.datetime.now() for interval calculations can be problematic if the system clock is adjusted. It is recommended to use time.monotonic() for measuring elapsed time and calculating wait durations to ensure robustness against clock jumps.

Suggested change
with self._entry_lock:
cutoff_time = datetime.datetime.now() - self._time_window
# drop the entries that are too old, as they are no longer relevant
while self._past_entries and self._past_entries[0] < cutoff_time:
self._past_entries.popleft()
if len(self._past_entries) < self._access_limit:
self._past_entries.append(datetime.datetime.now())
return 0.0 # no waiting was needed
to_wait = (self._past_entries[0] - cutoff_time).total_seconds()
time.sleep(to_wait)
self._past_entries.append(datetime.datetime.now())
return to_wait
def __enter__(self):
with self._entry_lock:
cutoff_time = time.monotonic() - self._time_window.total_seconds()
# drop the entries that are too old, as they are no longer relevant
while self._past_entries and self._past_entries[0] < cutoff_time:
self._past_entries.popleft()
if len(self._past_entries) < self._access_limit:
self._past_entries.append(time.monotonic())
return 0.0 # no waiting was needed
to_wait = self._past_entries[0] - cutoff_time
time.sleep(to_wait)
self._past_entries.append(time.monotonic())
return to_wait

value = getattr(record, field_name, None)
if value is not None:
log_obj[field_name] = value
return json.dumps(log_obj)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Per the general rules, dictionaries should be programmatically sorted before being serialized to ensure consistent key ordering in the output.

Suggested change
return json.dumps(log_obj)
return json.dumps(dict(sorted(log_obj.items())))
References
  1. To ensure dictionary keys remain sorted without manual effort, programmatically sort the dictionary before returning it (e.g., using dict(sorted(metadata.items()))) instead of relying on manual ordering in the code.


# Return the response
api_response = operations_pb2.ListOperationsResponse()
json_format.Parse(response.content, api_response, ignore_unknown_fields=False)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Setting ignore_unknown_fields=False can cause the client to break if the server adds new fields to the response. It is generally safer to set this to True for forward compatibility, which is consistent with other parts of this library.

Suggested change
json_format.Parse(response.content, api_response, ignore_unknown_fields=False)
json_format.Parse(response.content, api_response, ignore_unknown_fields=True)

Comment on lines +308 to +310
payload = json.loads(content.decode("utf-8"))
request_url = "{host}{uri}".format(host=self._host, uri=uri)
raise core_exceptions.format_http_response_error(response, method, request_url, payload) # type: ignore
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The response content might not be valid JSON (e.g., if an intermediate proxy returns an HTML error page). Parsing it directly with json.loads can raise a JSONDecodeError. It is safer to handle this exception and provide a fallback payload.

Suggested change
payload = json.loads(content.decode("utf-8"))
request_url = "{host}{uri}".format(host=self._host, uri=uri)
raise core_exceptions.format_http_response_error(response, method, request_url, payload) # type: ignore
decoded_content = content.decode("utf-8")
try:
payload = json.loads(decoded_content)
except json.JSONDecodeError:
payload = {"error": {"message": decoded_content or "unknown error"}}
request_url = "{host}{uri}".format(host=self._host, uri=uri)
raise core_exceptions.format_http_response_error(response, method, request_url, payload) # type: ignore

@parthea parthea marked this pull request as ready for review February 17, 2026 19:33
@parthea parthea requested review from a team as code owners February 17, 2026 19:33
@parthea parthea added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Feb 17, 2026
@parthea
Copy link
Copy Markdown
Contributor Author

parthea commented Feb 17, 2026

This PR is ready for review but not merge

@parthea parthea assigned daniel-sanche and unassigned parthea Feb 17, 2026
@parthea parthea removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Feb 17, 2026
@parthea parthea merged commit e1b4352 into main Feb 17, 2026
28 checks passed
@parthea parthea deleted the migration.python-api-core.migration.2026-02-13_19-20-54.migrate branch February 17, 2026 20:58
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.