cube-js/cube · error · Error

No CSV files were obtained from the bucket

Error message

No CSV files were obtained from the bucket

What it means

A sentinel guard in extractFilesFromGCS: after listing GCS objects under the `<tableName>/` prefix via bucket.getFiles, the returned file list was empty. This means the export bucket contains no CSV objects at the expected prefix — typically the upstream unload/export to GCS never ran, wrote to a different prefix/bucket, or the configured credentials/bucket name point at the wrong location. It signals an export-pipeline misconfiguration rather than a query failure.

Source

Thrown at packages/cubejs-base-driver/src/storage-fs/gcs.fs.ts:52

      ? { credentials: gcsConfig.credentials, projectId: gcsConfig.credentials.project_id }
      : undefined
  );

  const bucket = storage.bucket(bucketName);
  const [files] = await bucket.getFiles({ prefix: `${tableName}/` });

  if (files.length) {
    const csvFiles = await Promise.all(files.map(async (file) => {
      const [url] = await file.getSignedUrl({
        action: 'read',
        expires: new Date(new Date().getTime() + 60 * 60 * 1000)
      });
      return url;
    }));

    return csvFiles;
  } else {
    throw new Error('No CSV files were obtained from the bucket');
  }
}

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Verify the unload job completed and objects were written to the expected bucket/prefix
  2. Check bucket name and prefix configuration in the driver's unload options
  3. Verify GCS credentials have storage.objects.list/read permissions
  4. Retry the unload and re-extract after objects exist

Example fix

// before
unload: { bucket: 'cube-unloads', prefix: 'wrong-prefix' } // no CSVs listed
// after
unload: { bucket: 'cube-unloads', prefix: 'exports' } // matches unload output
Defensive patterns

Strategy: retry

Validate before calling

const [files] = await bucket.getFiles({ prefix });
if (!files.some(f => f.name.endsWith('.csv'))) throw new Error('unload produced no CSV objects');

Try / catch

try {
  urls = await extractFilesFromGCS(...);
} catch (e) {
  if (/No CSV files were obtained/.test(e.message)) {
    await sleep(2000);
    return extractFilesFromGCS(...);
  }
  throw e;
}

Prevention

When it happens

Trigger: GCS bucket/prefix contains no CSV objects at the time of listing after an unload (unload produced nothing or listed the wrong location).

Common situations: Unload job failed or extracted zero rows, wrong bucket or prefix configured, GCS permissions preventing object listing, eventual consistency/delay right after unload.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/bfcbd7d76296e4dc. Report an issue: GitHub.