From 72c291525133730bfb66150f2170741b565e9f23 Mon Sep 17 00:00:00 2001 From: bernardhanna Date: Mon, 30 Nov 2026 11:42:58 +0000 Subject: [PATCH] Reject glued BULK_UPLOAD_TEMP_DISK values so bulk upload works again. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A missing newline in Forge .env turned the disk name into localFACEBOOK_CLIENT_ID=…; fall back to the cloud disk when the configured name is invalid. Co-authored-by: Cursor --- app/Services/BulkEventUploadCache.php | 18 +++++++++++++++--- tests/Unit/BulkEventUploadCacheTest.php | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/app/Services/BulkEventUploadCache.php b/app/Services/BulkEventUploadCache.php index 4b40447b4..10deb75a2 100644 --- a/app/Services/BulkEventUploadCache.php +++ b/app/Services/BulkEventUploadCache.php @@ -27,21 +27,33 @@ public static function key(string $token): string /** * Shared temp disk for validate → import. Never use `local` on deployed apps * (Forge may still set BULK_UPLOAD_TEMP_DISK=local from the old example). + * Also reject glued .env values like `localFACEBOOK_CLIENT_ID=…`. */ public static function tempDisk(?string $cachedDisk = null): string { $configured = (string) ($cachedDisk ?: config('filesystems.bulk_upload_temp_disk', 's3')); $cloud = (string) config('filesystems.cloud', 's3'); + $disks = config('filesystems.disks', []); if (app()->environment('local', 'testing')) { return $configured !== '' ? $configured : 'local'; } - if ($configured === '' || $configured === 'local') { - return $cloud !== '' ? $cloud : 's3'; + $usable = $configured !== '' + && $configured !== 'local' + && ! str_contains($configured, '=') + && is_array($disks) + && array_key_exists($configured, $disks); + + if ($usable) { + return $configured; + } + + if ($cloud !== '' && is_array($disks) && array_key_exists($cloud, $disks)) { + return $cloud; } - return $configured; + return 's3'; } /** diff --git a/tests/Unit/BulkEventUploadCacheTest.php b/tests/Unit/BulkEventUploadCacheTest.php index f9c82a9c7..27a8a92e4 100644 --- a/tests/Unit/BulkEventUploadCacheTest.php +++ b/tests/Unit/BulkEventUploadCacheTest.php @@ -43,4 +43,20 @@ public function test_temp_disk_rejects_local_outside_local_environment(): void $this->assertSame('s3', BulkEventUploadCache::tempDisk('local')); $this->assertSame('s3', BulkEventUploadCache::tempDisk('s3')); } + + public function test_temp_disk_rejects_glued_env_disk_name(): void + { + config([ + 'filesystems.bulk_upload_temp_disk' => 'localFACEBOOK_CLIENT_ID=138145760054704', + 'filesystems.cloud' => 's3', + 'app.env' => 'production', + ]); + app()->detectEnvironment(fn () => 'production'); + + $this->assertSame('s3', BulkEventUploadCache::tempDisk()); + $this->assertSame( + 's3', + BulkEventUploadCache::tempDisk('localFACEBOOK_CLIENT_ID=138145760054704') + ); + } }