Skip to content

fix: Execution.create() 503 from credentials annotation typo and missing metadata store init#6611

Open
javabrett wants to merge 1 commit intogoogleapis:mainfrom
javabrett:fix/execution-create-credentials-bug
Open

fix: Execution.create() 503 from credentials annotation typo and missing metadata store init#6611
javabrett wants to merge 1 commit intogoogleapis:mainfrom
javabrett:fix/execution-create-credentials-bug

Conversation

@javabrett
Copy link
Copy Markdown

Summary

Fixes #6610.

Two bugs in metadata/execution.py caused Execution.create() to fail with 503 Getting metadata from plugin failed with error: before_request:

  1. Credentials annotation typo (create() line 103, _create() line 181): Used credentials=Optional[auth_credentials.Credentials] (assignment, =) instead of credentials: Optional[auth_credentials.Credentials] = None (annotation with default, :). The = form makes the default value the typing.Optional type object itself (a _UnionGenericAlias), not None. This non-None object is passed to the gRPC auth stack, which calls .before_request() on it, producing the 503. Present since PR feat: Vertex AI Experiments GA #1410 (June 2022). artifact.py and context.py both have the correct : ... = None syntax.

  2. Missing ensure_default_metadata_store_exists() call: Artifact.create() calls metadata_store._MetadataStore.ensure_default_metadata_store_exists() before delegating to _create(), but Execution.create() skipped this. Standalone Execution.create() (without a prior Artifact.create() or aiplatform.init(experiment=...) warming the store) would fail.

Changes

  • google/cloud/aiplatform/metadata/execution.py: Fix credentials annotation on both create() and _create(). Add ensure_default_metadata_store_exists() call in create() matching Artifact.create().
  • tests/unit/aiplatform/test_metadata_resources.py: 3 regression tests:
    • test_create_credentials_default_is_none -- verifies both create() and _create() default to None
    • test_create_calls_ensure_default_metadata_store_exists -- verifies the store init is called for default store
    • test_create_skips_ensure_for_non_default_metadata_store -- verifies it's skipped for non-default stores

Test plan

  • 3 new tests FAIL against unfixed code (2 FAILED, 1 PASSED as expected)
  • 3 new tests PASS against fixed code
  • All 13 existing TestExecution tests pass (zero regressions)

…ing metadata store init

Fixes googleapis#6610.

Two bugs in `metadata/execution.py` caused `Execution.create()` to fail
with "503 Getting metadata from plugin failed with error: before_request":

1. The `credentials` parameter on both `create()` and `_create()` used
   `=` instead of `:` for the type annotation:
   `credentials=Optional[auth_credentials.Credentials]` instead of
   `credentials: Optional[auth_credentials.Credentials] = None`.
   This made the default value the `typing.Optional` type object itself
   (not `None`), which the gRPC auth stack tried to call
   `.before_request()` on.

2. `create()` skipped the `ensure_default_metadata_store_exists()` call
   that `Artifact.create()` makes, so standalone `Execution.create()`
   would also fail if no prior operation had initialized the metadata
   store.

Both issues have been present since PR googleapis#1410 (June 2022).
`artifact.py` and `context.py` both have the correct annotation.
@javabrett javabrett requested a review from a team as a code owner April 19, 2026 07:52
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: vertex-ai Issues related to the googleapis/python-aiplatform API. labels Apr 19, 2026
@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 19, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: vertex-ai Issues related to the googleapis/python-aiplatform API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Execution.create() fails with 503 due to credentials annotation typo

1 participant