Skip to content

Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.

fix(media): don't 500 when the Unsplash/Giphy key is set to null

Paulo Sérgio Dantas4e80fd54b7ba
diff --git a/app/Services/GiphyService.php b/app/Services/GiphyService.php
index e60ff667a..f5e674d46 100644
--- a/app/Services/GiphyService.php
+++ b/app/Services/GiphyService.php
@@ -15,7 +15,7 @@ class GiphyService
public function __construct()
{
- $this->apiKey = config('services.giphy.api_key', '');
+ $this->apiKey = (string) config('services.giphy.api_key', '');
}
/**
diff --git a/app/Services/UnsplashService.php b/app/Services/UnsplashService.php
index 5ac1ad9a6..db16237e1 100644
--- a/app/Services/UnsplashService.php
+++ b/app/Services/UnsplashService.php
@@ -15,7 +15,7 @@ class UnsplashService
public function __construct()
{
- $this->accessKey = config('services.unsplash.access_key', '');
+ $this->accessKey = (string) config('services.unsplash.access_key', '');
}
/**
diff --git a/tests/Unit/Services/MediaSearchKeyFallbackTest.php b/tests/Unit/Services/MediaSearchKeyFallbackTest.php
new file mode 100644
index 000000000..6fa85c474
--- /dev/null
+++ b/tests/Unit/Services/MediaSearchKeyFallbackTest.php
@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Services\GiphyService;
+use App\Services\UnsplashService;
+
+test('unsplash service tolerates a null access key without throwing', function () {
+ config(['services.unsplash.access_key' => null]);
+
+ $result = (new UnsplashService)->search('cats');
+
+ expect($result)->toBe(['results' => [], 'total' => 0, 'total_pages' => 0]);
+});
+
+test('giphy service tolerates a null api key without throwing', function () {
+ config(['services.giphy.api_key' => null]);
+
+ $result = (new GiphyService)->search('cats');
+
+ expect($result)->toBe(['results' => [], 'total' => 0, 'total_pages' => 0]);
+});