googleapis/mcp-toolbox · error

failed to open source %q: %w

Error message

failed to open source %q: %w

What it means

Error "failed to open source %q: %w" thrown in googleapis/mcp-toolbox.

Source

Thrown at internal/sources/cloudstorage/cloudstorage.go:471

		"contentType": reader.Attrs.ContentType,
	}, nil
}

// UploadObject streams a local file into a GCS object. When contentType is
// empty, mime.TypeByExtension is consulted; if inference still fails the
// writer's ContentType is left unset so GCS content-sniffs the first 512 bytes.
// The returned contentType is the post-Close value from w.Attrs(), i.e. what
// GCS actually recorded.
func (s *Source) UploadObject(ctx context.Context, bucket, object, source, contentType string) (map[string]any, error) {
	if err := s.validateBucket(bucket); err != nil {
		return nil, err
	}
	if err := s.validateLocalPath(source); err != nil {
		return nil, err
	}
	f, err := os.Open(source)
	if err != nil {
		return nil, fmt.Errorf("failed to open source %q: %w", source, err)
	}
	defer f.Close()

	if contentType == "" {
		contentType = mime.TypeByExtension(filepath.Ext(source))
	}

	w := s.client.Bucket(bucket).Object(object).NewWriter(ctx)
	if contentType != "" {
		w.ContentType = contentType
	}

	n, err := io.Copy(w, f)
	if err != nil {
		_ = w.Close()
		return nil, fmt.Errorf("failed to copy %q to object %q in bucket %q: %w", source, object, bucket, err)
	}
	if err := w.Close(); err != nil {

View on GitHub (pinned to 8cc6e09de2)

When it happens

Trigger: Thrown at internal/sources/cloudstorage/cloudstorage.go:471 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/23fbe3835500ec85. Report an issue: GitHub.