feat(artifacts): add get_authenticated_url and get_signed_url to GcsArtifactService - #6818
Open
patil-prajwal wants to merge 1 commit into
Open
feat(artifacts): add get_authenticated_url and get_signed_url to GcsArtifactService#6818patil-prajwal wants to merge 1 commit into
patil-prajwal wants to merge 1 commit into
Conversation
…rtifactService Add methods to GcsArtifactService for generating Google Cloud Storage authenticated browser URLs (https://storage.cloud.google.com/...) and time-limited signed URLs directly for client and frontend consumption.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Problem:
Currently,
GcsArtifactService.get_artifact_version()only returnscanonical_uriings://<bucket>/<blob_name>format. Whilegs://URIs work seamlessly when passing file references directly to Vertex AI / Gemini API models (types.FileData(file_uri="gs://...")), web applications, chat frontends, and external API consumers cannot accessgs://links directly in a browser.Developers are currently forced to manually perform fragile string replacements (e.g.
.replace("gs://", "https://storage.cloud.google.com/...")) or reach into internal Cloud Storage client objects (self.bucket.blob(...)) to generate accessible URLs.Solution:
Add two dedicated, async-compatible methods to
GcsArtifactService:get_authenticated_url()(and_get_authenticated_url_sync()):https://storage.cloud.google.com/{bucket_name}/{blob_name}).version=None. ReturnsNoneif the artifact does not exist.get_signed_url()(and_get_signed_url_sync()):Blob.generate_signed_url().expiration(timedelta,datetime, or integer seconds; defaults to 1 hour), HTTPmethod, and forwards extra keyword arguments.version=None. ReturnsNoneif the artifact does not exist.Testing Plan
Unit Tests:
Summary of passed pytest results:
test_gcs_get_authenticated_url_latest_version— PASSEDtest_gcs_get_authenticated_url_specific_version— PASSEDtest_gcs_get_authenticated_url_returns_none_for_missing— PASSEDtest_gcs_get_signed_url_latest_version— PASSEDtest_gcs_get_signed_url_returns_none_for_missing— PASSEDManual End-to-End (E2E) Tests:
Verified end-to-end URL resolution using mock GCS storage:
get_authenticated_urlcorrectly resolves the latest version and returnshttps://storage.cloud.google.com/test_bucket/app/user1/sess1/notes.txt/1.get_signed_urlcorrectly forwards expiration and method to generate time-limited signed URLs.Nonewhen the requested artifact does not exist.Checklist
Additional context
The
canonical_urifield onArtifactVersionis left untouched (gs://...) so backend model ingestion flows (SaveFilesAsArtifactsPlugin, Gemini multimodal file references) remain 100% backward-compatible.