GoogleContainerTools/skaffold · error
uploading sources to google storage: %w
Error message
uploading sources to google storage: %w
What it means
`UploadToGCS` wraps failures from `util.CreateTarGz`, which streams a tar.gz of the artifact's source dependencies directly into a GCS object writer. The error means the sources could not be archived and uploaded to the given GCS bucket/object — either the local archive creation failed (missing files, IO errors) or the streaming write to GCS failed mid-upload.
Source
Thrown at pkg/skaffold/sources/upload.go:34
package sources
import (
"context"
"fmt"
cstorage "cloud.google.com/go/storage"
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util"
)
// UploadToGCS uploads the artifact's sources to a GCS bucket.
func UploadToGCS(ctx context.Context, c *cstorage.Client, a *latest.Artifact, bucket, objectName string, dependencies []string) error {
w := c.Bucket(bucket).Object(objectName).NewWriter(ctx)
if err := util.CreateTarGz(ctx, w, a.Workspace, dependencies); err != nil {
return fmt.Errorf("uploading sources to google storage: %w", err)
}
return w.Close()
}
View on GitHub (pinned to a1189de023)
Solutions
- Verify GCS credentials and that the service account has Object Creator (roles/storage.objectCreator) on the bucket.
- Confirm the bucket exists and the objectName/bucket spelling is correct.
- Ensure all files listed in `dependencies` exist inside `a.Workspace` and are readable.
- Check network/proxy connectivity to storage.googleapis.com and retry transient failures.
Example fix
// before c := client.NewGCSClient(ctx) // no credentials/scopes err := sources.UploadToGCS(ctx, c, artifact, "my-bucket", "src.tgz", deps) // after // grant storage.objectCreator to the SA and authenticate: // gcloud auth application-default login (or attach storage scope) err := sources.UploadToGCS(ctx, c, artifact, "my-bucket", "src.tgz", verifiedDeps)
Defensive patterns
Strategy: validation
Validate before calling
for _, dep := range dependencies {
if _, err := os.Stat(filepath.Join(a.Workspace, dep)); err != nil {
return fmt.Errorf("missing dependency %q before GCS upload: %w", dep, err)
}
}
if err := c.Bucket(bucket).Objects(ctx, nil); err != nil { // probe bucket access
return fmt.Errorf("bucket %q not accessible: %w", bucket, err)
} Try / catch
err := sources.UploadToGCS(ctx, client, artifact, bucket, obj, deps)
if err != nil {
if strings.Contains(err.Error(), "uploading sources to google storage") {
log.Printf("GCS upload failed: %v; check credentials/bucket and retry", err)
}
return err
} Prevention
- Grant the service account roles/storage.objectCreator on the staging bucket.
- Run `gcloud auth application-default login` or attach storage scopes in CI.
- Validate all dependency paths exist under the workspace before uploading.
- Confirm network/proxy access to storage.googleapis.com from your environment.
When it happens
Trigger: Calling `UploadToGCS(ctx, client, artifact, bucket, objectName, dependencies)` where `dependencies` reference files that don't exist under `a.Workspace`, the workspace is unreadable, the GCS credentials are missing/invalid, the bucket doesn't exist or is not writable, or the network drops during upload.
Common situations: Cloud build workflows where the GCS staging bucket name is misspelled or the service account lacks storage.objects.create; source files deleted after dependency computation; 403 from GCS due to no storage scope on the VM; flaky network interrupting the multipart upload.
Related errors
- error closing GCS writer: %w
- error copying file to GCS: %w
- failed to iterate objects: %v
- failed to read object: %v
- failed to copy object to file: %v
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/f3a8704a0e5548dd.
Report an issue: GitHub.