Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: only treat a 404 bucket lookup as missing in the private-bucket migration script

aashu4b45299c2966
diff --git a/scripts/one-off/migrate-private-buckets.ts b/scripts/one-off/migrate-private-buckets.ts
index 1379a24870..a48a72ed50 100644
--- a/scripts/one-off/migrate-private-buckets.ts
+++ b/scripts/one-off/migrate-private-buckets.ts
@@ -105,8 +105,10 @@ async function listObjectKeys(
// error, so creating unconditionally logged one `buckets_pkey` error per
// company on every run.
async function bucketExists(companyId: string): Promise<boolean> {
- const { data } = await client.storage.getBucket(companyId);
- return Boolean(data);
+ const { error } = await client.storage.getBucket(companyId);
+ if (!error) return true;
+ if (String(error.statusCode) === "404") return false;
+ throw new Error(`Failed to read bucket ${companyId}: ${error.message}`);
}
async function createBucket(companyId: string) {