{"record":{"id":"5d9491530002d491","repo":"ruvnet/ruflo","slug":"gcs-not-configured-set-gcs-bucket-environment-var","errorCode":null,"errorMessage":"GCS not configured. Set GCS_BUCKET environment variable.\nOr authenticate: gcloud auth login && gcloud config set project YOUR_PROJECT","messagePattern":"GCS not configured\\. Set GCS_BUCKET environment variable\\.\nOr authenticate: gcloud auth login && gcloud config set project YOUR_PROJECT","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/transfer/storage/gcs.ts","lineNumber":111,"sourceCode":"  const hash = crypto.createHash('sha256').update(content).digest('hex');\n  return `cfp-${hash.slice(0, 16)}`;\n}\n\n/**\n * Upload content to Google Cloud Storage using gcloud CLI\n */\nexport async function uploadToGCS(\n  content: Buffer,\n  options: {\n    name?: string;\n    contentType?: string;\n    config?: GCSConfig;\n    metadata?: Record<string, string>;\n  } = {}\n): Promise<GCSUploadResult> {\n  const config = options.config || getGCSConfig();\n  if (!config) {\n    throw new Error(\n      'GCS not configured. Set GCS_BUCKET environment variable.\\n' +\n      'Or authenticate: gcloud auth login && gcloud config set project YOUR_PROJECT'\n    );\n  }\n\n  const contentId = generateContentId(content);\n  const checksum = crypto.createHash('sha256').update(content).digest('hex');\n  const fileName = options.name || `${contentId}.cfp.json`;\n\n  // Validate filename to prevent path traversal\n  if (!/^[a-zA-Z0-9._\\-]+$/.test(fileName) || fileName.includes('..')) {\n    throw new Error(`Invalid filename: ${fileName}`);\n  }\n\n  const objectPath = config.prefix ? `${config.prefix}/${fileName}` : fileName;\n\n  // S-1: Validate bucket name and object path to prevent command injection\n  if (!isValidBucketName(config.bucket)) {","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/transfer/storage/gcs.ts#L93-L129","documentation":"uploadToGCS() starts from getGCSConfig(), which assembles configuration from the environment (GCS_BUCKET etc.). When that yields nothing — GCS_BUCKET unset and no explicit options.config — the function throws before doing any work, with the two recovery paths in the message: set GCS_BUCKET, or authenticate via gcloud. The upload itself shells out to `gcloud storage cp`, so both a bucket and a working gcloud login are required.","triggerScenarios":"Calling uploadToGCS(content) with GCS_BUCKET unset in the process env; running in CI where the variable was never added to the job environment; passing no options.config while relying purely on ambient environment.","commonSituations":"Fresh machines that never ran gcloud auth login; env vars defined in .env but not loaded by the Node process; deploy pipelines that configure other providers (S3/web3) but not GCS.","solutions":["export GCS_BUCKET=your-bucket (plus project config via gcloud config set project YOUR_PROJECT) and rerun","Authenticate once: gcloud auth login && gcloud config set project YOUR_PROJECT (the uploader invokes gcloud storage cp)","Or pass explicit configuration programmatically via options.config (GCSConfig with bucket/prefix)","Verify with `gcloud storage ls gs://your-bucket` that credentials and bucket both work before uploading"],"exampleFix":"# before\nnpx claude-flow hooks transfer store --storage gcs\n# throws: GCS not configured. Set GCS_BUCKET...\n\n# after\ngcloud auth login && gcloud config set project my-project\nexport GCS_BUCKET=my-pattern-bucket\nnpx claude-flow hooks transfer store --storage gcs","handlingStrategy":"validation","validationCode":"const bucket = process.env.GCS_BUCKET;\nif (!bucket) {\n  throw new Error('GCS storage selected but GCS_BUCKET is not set — configure it or choose another storage backend');\n}\nawait uploadToGCS(content, { name });","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate storage backend configuration at process startup, not at first upload","Run `gcloud auth login` and `gcloud config set project` on fresh machines — the uploader shells out to gcloud","Add GCS_BUCKET to your deployment env checklist alongside other provider secrets"],"tags":["gcs","cloud-storage","environment-variable","configuration","upload"],"backgroundTag":"missing-environment-variable","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}