From 15638d1672e5dbd9ce3a51b2c132cd6a7facff1f Mon Sep 17 00:00:00 2001 From: isaacclad Date: Fri, 17 Jul 2026 16:09:31 +0000 Subject: [PATCH] Fall back to sole Queue branch when Care branch names differ. Free single-location Queue orgs often use a default name like Main Branch while Care stubs send Main; reuse the only branch. Co-authored-by: Cursor --- app/Services/Queue/QueueClient.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Services/Queue/QueueClient.php b/app/Services/Queue/QueueClient.php index 985f697..296b92c 100644 --- a/app/Services/Queue/QueueClient.php +++ b/app/Services/Queue/QueueClient.php @@ -298,13 +298,19 @@ class QueueClient try { $this->ensureBranch($owner, ['name' => $branchName]); } catch (RequestException $e) { - // Free Queue plans may already be at branch cap — continue if branch already exists. + // Free Queue plans may already be at branch cap — continue if a branch can be resolved. if ($e->response?->status() !== 422) { throw $e; } - $existing = collect($this->branches($owner))->first( + $branches = collect($this->branches($owner)); + $existing = $branches->first( fn ($b) => strcasecmp((string) ($b['name'] ?? ''), $branchName) === 0 ); + if (! $existing && $branches->count() === 1) { + // Single-location Queue orgs often use a different default name (e.g. "Main Branch"). + $existing = $branches->first(); + $branchName = (string) ($existing['name'] ?? $branchName); + } if (! $existing) { throw $e; }