Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Rules/ContentTypeMatchesPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
$parentKey = Str::beforeLast($attribute, '.');
$accountId = data_get($this->data, $parentKey.'.social_account_id');

if (! $accountId) {
if (! $accountId || ! Str::isUuid((string) $accountId)) {
return;
}

Expand Down
8 changes: 8 additions & 0 deletions tests/Unit/Rules/ContentTypeMatchesPlatformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ function runMatchesPlatformRule(string $contentType, ?string $accountId, array $
expect(runMatchesPlatformRule(ContentType::XPost->value, null))->toBe([]);
});

test('skips validation without querying the database when social_account_id is not a uuid', function () {
// Regression: a non-uuid social_account_id (e.g. an MCP client sending a
// placeholder string) must not reach SocialAccount::find(), which throws
// a QueryException on Postgres for invalid uuid input instead of
// returning no rows.
expect(runMatchesPlatformRule(ContentType::XPost->value, 'threads-account'))->toBe([]);
});

test('skips validation when content_type is not a known enum value', function () {
$workspace = Workspace::factory()->create();
$linkedin = SocialAccount::factory()->create([
Expand Down