You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "fallintoplace (via GitHub)" <gi...@apache.org> on 2026/07/28 18:40:47 UTC

[PR] fix(io/gcs): propagate application-default credential errors [iceberg-go]

fallintoplace opened a new pull request, #1584:
URL: https://github.com/apache/iceberg-go/pull/1584

   ## What changed
   
   Return application-default credential discovery errors from GCS configuration with source context.
   
   ## Why
   
   ADC errors were discarded and a nil credential result was interpreted as anonymous access. Malformed or missing configured credentials could therefore fail later with an unrelated storage authorization error. Anonymous access remains available explicitly through `gcs.no-auth`.
   
   The regression test uses a missing ADC file and verifies that `gcs.no-auth` still takes precedence.
   
   ## Testing
   
   - `go test ./io/gocloud -run TestGCSCredentials`
   - `go vet ./io/gocloud`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(io/gcs): propagate application-default credential errors [iceberg-go]

Posted by "laskoviymishka (via GitHub)" <gi...@apache.org>.
laskoviymishka merged PR #1584:
URL: https://github.com/apache/iceberg-go/pull/1584


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(io/gcs): propagate application-default credential errors [iceberg-go]

Posted by "laskoviymishka (via GitHub)" <gi...@apache.org>.
laskoviymishka commented on code in PR #1584:
URL: https://github.com/apache/iceberg-go/pull/1584#discussion_r3681109608


##########
io/gocloud/gcs.go:
##########
@@ -131,7 +131,10 @@ func gcsCredentials(ctx context.Context, props map[string]string) (*google.Crede
 		return parse(data, fmt.Sprintf("%s %q", io.GCSKeyPath, path))
 	}
 
-	creds, _ := gcp.DefaultCredentials(ctx)
+	creds, err := gcp.DefaultCredentials(ctx)

Review Comment:
   agreed that discarding the ADC error here was a real bug — silently returning nil creds and falling through to anonymous access hides genuine auth failures.
   
   the thing I'd want sorted before merge is that this also flips behavior for anyone who was relying on that silent fallback: public buckets, the fake-gcs emulator, or any non-GCP env without ADC used to quietly get an anonymous client, and now they hard-fail the moment they open a `gs://` path. Java defers ADC lazily via `StorageOptions` and never fails eagerly at FileIO init, so we'd be diverging from the Java client here.
   
   two ways I could see going — preserve the old `nil, nil` → anonymous semantics when `DefaultCredentials` fails, or keep the eager error but make it self-documenting so the migration path is obvious:
   
   ```go
   return nil, fmt.Errorf("gcs: no credentials found; set %s=true for anonymous/public bucket access: %w", io.GCSNoAuth, err)
   ```
   
   I lean toward the second since failing loud on a real auth error is the better default, but either way I'd call this out as a breaking change in the PR description. wdyt?



##########
io/gocloud/gcs.go:
##########
@@ -131,7 +131,10 @@ func gcsCredentials(ctx context.Context, props map[string]string) (*google.Crede
 		return parse(data, fmt.Sprintf("%s %q", io.GCSKeyPath, path))
 	}
 
-	creds, _ := gcp.DefaultCredentials(ctx)
+	creds, err := gcp.DefaultCredentials(ctx)
+	if err != nil {

Review Comment:
   small defensive one while we're here: if `DefaultCredentials` ever returns `(nil, nil)`, we fall straight back to the anonymous path — the exact silent fallback this PR is removing. gocloud's `gcp` doesn't do that today, but the contract isn't enforced at the call site. a `if creds == nil` guard before the return would close it off.



##########
io/gocloud/gcs_integration_test.go:
##########
@@ -115,6 +115,7 @@ func (s *GCSIOTestSuite) TestGCSWarehouse() {
 		"type":            "sql",
 		"warehouse":       fmt.Sprintf("gs://%s/iceberg/", gcsBucketName),
 		io.GCSEndpoint:    fmt.Sprintf("http://%s/", gcsEndpoint),
+		io.GCSNoAuth:      "true",

Review Comment:
   this is the right fix for the emulator — fake-gcs-server serves no real ADC, so without no-auth the suite would now hard-fail in CI. worth a one-line comment saying exactly that, though; otherwise it reads as an unexplained flag and someone may drop it later thinking it's redundant.



##########
io/gocloud/gcs_test.go:
##########
@@ -142,6 +142,19 @@ func TestGCSCredentialsNoAuth(t *testing.T) {
 	assert.Nil(t, creds)
 }
 
+func TestGCSCredentialsPropagatesADCError(t *testing.T) {
+	t.Setenv("GOOGLE_APPLICATION_CREDENTIALS", filepath.Join(t.TempDir(), "missing.json"))

Review Comment:
   good case to have. it forces ADC to fail at the env-var step, but it doesn't cover the more common dev failure — no env var set and no creds anywhere (fresh machine, container with nothing mounted), where ADC falls through the well-known-file and metadata-server lookups before failing. a sub-case with `t.Setenv("GOOGLE_APPLICATION_CREDENTIALS", "")` would exercise that path too.



##########
io/gocloud/gcs_test.go:
##########
@@ -142,6 +142,19 @@ func TestGCSCredentialsNoAuth(t *testing.T) {
 	assert.Nil(t, creds)
 }
 
+func TestGCSCredentialsPropagatesADCError(t *testing.T) {
+	t.Setenv("GOOGLE_APPLICATION_CREDENTIALS", filepath.Join(t.TempDir(), "missing.json"))
+
+	creds, err := gcsCredentials(context.Background(), nil)
+	require.Error(t, err)

Review Comment:
   `require.ErrorContains` already implies the error is non-nil, so the `require.Error` above it is redundant — I'd drop it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(io/gcs): propagate application-default credential errors [iceberg-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #1584:
URL: https://github.com/apache/iceberg-go/pull/1584#discussion_r3732157731


##########
io/gocloud/gcs_test.go:
##########
@@ -142,6 +144,40 @@ func TestGCSCredentialsNoAuth(t *testing.T) {
 	assert.Nil(t, creds)
 }
 
+func TestGCSCredentialsPropagatesADCError(t *testing.T) {
+	t.Run("missing configured file", func(t *testing.T) {
+		t.Setenv("GOOGLE_APPLICATION_CREDENTIALS", filepath.Join(t.TempDir(), "missing.json"))
+
+		creds, err := gcsCredentials(context.Background(), nil)
+		require.ErrorContains(t, err, "gcs: no credentials found")
+		require.ErrorContains(t, err, io.GCSNoAuth)
+		assert.Nil(t, creds)
+	})
+
+	t.Run("no configured credentials", func(t *testing.T) {
+		t.Setenv("GOOGLE_APPLICATION_CREDENTIALS", "")
+
+		creds, err := gcsCredentialsWithDefault(context.Background(), nil,
+			func(context.Context) (*google.Credentials, error) {
+				return nil, errors.New("application default credentials unavailable")
+			})
+		require.ErrorContains(t, err, "gcs: no credentials found")
+		require.ErrorContains(t, err, io.GCSNoAuth)
+		assert.Nil(t, creds)
+	})
+
+	t.Run("nil credentials", func(t *testing.T) {
+		creds, err := gcsCredentialsWithDefault(context.Background(), nil,
+			func(context.Context) (*google.Credentials, error) { return nil, nil })
+		require.ErrorContains(t, err, "gcs: no credentials found")
+		assert.Nil(t, creds)
+	})
+
+	creds, err := gcsCredentials(context.Background(), map[string]string{io.GCSNoAuth: "true"})

Review Comment:
   Non-blocking: this repeats the existing `TestGCSCredentialsNoAuth` assertion. Consider calling `gcsCredentialsWithDefault` here with `gcs.no-auth=true` and a `defaultCredentials` function that panics; that would prove the anonymous path short-circuits ADC lookup, which is the more valuable inverse property.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org