{"record":{"id":"c2e5ce0fe7f9c331","repo":"googleapis/mcp-toolbox","slug":"failed-to-close-destination-q-w","errorCode":null,"errorMessage":"failed to close destination %q: %w","messagePattern":"failed to close destination %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/cloudstorage/cloudstorage.go","lineNumber":447,"sourceCode":"\t\tflags |= os.O_TRUNC\n\t} else {\n\t\tflags |= os.O_EXCL\n\t}\n\tf, err := os.OpenFile(destination, flags, 0o644)\n\tif err != nil {\n\t\tif errors.Is(err, os.ErrExist) {\n\t\t\treturn nil, fmt.Errorf(\"destination %q: %w\", destination, cloudstoragecommon.ErrDestinationExists)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"failed to open destination %q: %w\", destination, err)\n\t}\n\n\tn, err := io.Copy(f, reader)\n\tif err != nil {\n\t\t_ = f.Close()\n\t\treturn nil, fmt.Errorf(\"failed to write object %q to %q: %w\", object, destination, err)\n\t}\n\tif err := f.Close(); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to close destination %q: %w\", destination, err)\n\t}\n\n\treturn map[string]any{\n\t\t\"destination\": destination,\n\t\t\"bytes\":       n,\n\t\t\"contentType\": reader.Attrs.ContentType,\n\t}, nil\n}\n\n// UploadObject streams a local file into a GCS object. When contentType is\n// empty, mime.TypeByExtension is consulted; if inference still fails the\n// writer's ContentType is left unset so GCS content-sniffs the first 512 bytes.\n// The returned contentType is the post-Close value from w.Attrs(), i.e. what\n// GCS actually recorded.\nfunc (s *Source) UploadObject(ctx context.Context, bucket, object, source, contentType string) (map[string]any, error) {\n\tif err := s.validateBucket(bucket); err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/cloudstorage/cloudstorage.go#L429-L465","documentation":"Error \"failed to close destination %q: %w\" thrown in googleapis/mcp-toolbox.","triggerScenarios":"Thrown at internal/sources/cloudstorage/cloudstorage.go:447 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}