Skip to content

Refactor credential types to support multiple cloud storage backends#584

Open
sfc-gh-pczajka wants to merge 1 commit intomainfrom
pczajka/gcs-type-refactoring
Open

Refactor credential types to support multiple cloud storage backends#584
sfc-gh-pczajka wants to merge 1 commit intomainfrom
pczajka/gcs-type-refactoring

Conversation

@sfc-gh-pczajka
Copy link
Contributor

Summary

  • Replace S3-only Credentials struct with CloudCredentials enum supporting S3 and GCS at the type level
  • Add LocationType enum and extend StageInfo with presigned_url field
  • Update query response parsing to build credentials based on locationType from server
  • GCS and Azure operations return UnsupportedStorageType error (implementation in follow-up PR)

Part 1 of 2 — type system refactoring only, no new cloud backend functionality.

Test plan

  • All 251 sf_core unit tests pass
  • All 32 Python e2e put/get tests pass (S3 regression)
  • Pre-commit hooks pass (rustfmt, clippy, cargo check)

🤖 Generated with Claude Code

@sfc-gh-pczajka sfc-gh-pczajka requested a review from a team as a code owner March 18, 2026 14:59
Copilot AI review requested due to automatic review settings March 18, 2026 14:59
@graphite-app
Copy link

graphite-app bot commented Mar 18, 2026

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge_queue - adds this PR to the back of the merge queue
  • priority_merge_queue - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors Snowflake stage credential handling in sf_core to support multiple cloud storage backends by introducing typed location/credential variants and updating query-response parsing and file-transfer entry points accordingly.

Changes:

  • Added LocationType and CloudCredentials to represent cloud backends and credentials at the type level.
  • Extended StageInfo with location_type and presigned_url, and updated Snowflake query response parsing to populate them.
  • Updated upload/download dispatch to branch by location_type, returning UnsupportedStorageType for non-S3 backends (for now).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
sf_core/src/rest/snowflake/query_response.rs Parses locationType/presignedUrl and builds typed file_manager::StageInfo credentials based on backend.
sf_core/src/file_manager/types.rs Introduces LocationType, CloudCredentials, and extends StageInfo to carry backend + optional presigned URL.
sf_core/src/file_manager/mod.rs Routes upload/download by location_type and adds UnsupportedStorageType error variant.
sf_core/src/file_manager/file_transfer.rs Updates S3 client creation to pull credentials from the CloudCredentials enum.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor Author

sfc-gh-pczajka commented Mar 20, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge_queue - adds this PR to the back of the merge queue
  • priority_merge_queue - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Replace the S3-only Credentials struct with a CloudCredentials enum
that supports S3 and GCS credential types at the type level. Add
LocationType enum and extend StageInfo with presigned_url field.
Update query response parsing to build credentials based on location
type. GCS and Azure operations return UnsupportedStorageType for now.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 20, 2026 14:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors Snowflake file-transfer stage metadata and credential modeling so the type system can represent multiple cloud storage backends (S3 today, GCS/Azure as stubs), and wires the new enums through query response parsing and the file manager.

Changes:

  • Introduces LocationType and CloudCredentials (S3/GCS) and extends StageInfo with location_type and presigned_url.
  • Updates query response parsing to derive file_manager::StageInfo based on locationType and construct backend-specific credentials.
  • Updates S3 transfer code to consume CloudCredentials::S3 and adds explicit “missing S3 credentials” errors.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
sf_core/src/rest/snowflake/query_response.rs Parses locationType/presignedUrl and constructs backend-specific StageInfo + credentials.
sf_core/src/file_manager/types.rs Adds LocationType, CloudCredentials, and new StageInfo fields to represent multiple backends.
sf_core/src/file_manager/s3_transfer.rs Refactors S3 transfer to require S3 credentials variant and improves Snafu context usage.
sf_core/src/file_manager/mod.rs Routes upload/download by LocationType, returning unsupported errors for non-S3 backends.
Comments suppressed due to low confidence (2)

sf_core/src/file_manager/s3_transfer.rs:180

  • create_s3_client matches on stage_info.creds by value, which moves the enum out of a borrowed &StageInfo and should not compile. Match on a reference instead (e.g., match &stage_info.creds { CloudCredentials::S3 { ... } => ... }) or destructure via let CloudCredentials::S3 { .. } = &stage_info.creds to avoid moving.
    sf_core/src/file_manager/s3_transfer.rs:228
  • The From<S3CredentialError> impls construct MissingS3Credentials with Location::default(), which loses the actual call-site #[snafu(implicit)] location and makes diagnostics much less useful. Prefer returning UploadFileError/DownloadFileError directly from create_s3_client (or use a Snafu context helper) so the implicit Location is captured at the point of failure.

@sfc-gh-pczajka sfc-gh-pczajka force-pushed the pczajka/gcs-type-refactoring branch from bf60f36 to 3291a41 Compare March 20, 2026 15:12
@sfc-gh-pczajka sfc-gh-pczajka enabled auto-merge (squash) March 20, 2026 15:15
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.

3 participants