googleapis/mcp-toolbox · error
failed to close destination %q: %w
Error message
failed to close destination %q: %w
What it means
Error "failed to close destination %q: %w" thrown in googleapis/mcp-toolbox.
Source
Thrown at internal/sources/cloudstorage/cloudstorage.go:447
flags |= os.O_TRUNC
} else {
flags |= os.O_EXCL
}
f, err := os.OpenFile(destination, flags, 0o644)
if err != nil {
if errors.Is(err, os.ErrExist) {
return nil, fmt.Errorf("destination %q: %w", destination, cloudstoragecommon.ErrDestinationExists)
}
return nil, fmt.Errorf("failed to open destination %q: %w", destination, err)
}
n, err := io.Copy(f, reader)
if err != nil {
_ = f.Close()
return nil, fmt.Errorf("failed to write object %q to %q: %w", object, destination, err)
}
if err := f.Close(); err != nil {
return nil, fmt.Errorf("failed to close destination %q: %w", destination, err)
}
return map[string]any{
"destination": destination,
"bytes": n,
"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
}View on GitHub (pinned to 8cc6e09de2)
When it happens
Trigger: Thrown at internal/sources/cloudstorage/cloudstorage.go:447 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/c2e5ce0fe7f9c331.
Report an issue: GitHub.