fix(api-tokens): open the tokens page when a token has unreadable scopes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2026-11-10 15:51:43 +01:00
co-authored by Claude Opus 5.5
parent 989c2238f8
commit 879bd5c42a
3 changed files with 7 additions and 2 deletions
@@ -0,0 +1,4 @@
---
type: fixed
---
Crashed the `Keys & Tokens` > `API Tokens` page with a 500 error for a token with scopes stored in an unexpected format
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Livewire\Forms;
use App\Services\Access\Grant;
use Laravel\Sanctum\PersonalAccessToken;
use Livewire\Form;
@@ -55,7 +56,7 @@ class ApiTokenForm extends Form
'description' => $token->name,
'permissions' => $permissions,
'scopeMode' => $token->scopes === null ? 'team' : 'selected',
'selectedScopes' => collect($token->scopes ?? [])->map(fn (array $scope) => "{$scope['scope']}:{$scope['uuid']}")->values()->all(),
'selectedScopes' => array_map(fn (Grant $scope) => "{$scope->scope->value}:{$scope->uuid}", Grant::listFrom($token->scopes)),
'expiresInDays' => self::KEEP_EXPIRY,
'keepLabel' => 'Keep current ('.($token->expires_at?->isPast() ? 'expired '.$currentExpiry : $currentExpiry).')',
];
+1 -1
View File
@@ -174,7 +174,7 @@ class ApiTokens extends Component
'search' => Str::lower(collect([$token->name, ...($token->abilities ?? [])])
->merge($token->scopes === null
? ['All resources in the team']
: collect($token->scopes)->map(fn ($scope) => $scopeLabels[($scope['scope'] ?? '').':'.($scope['uuid'] ?? '')] ?? null)->filter())
: collect(Grant::listFrom($token->scopes))->map(fn (Grant $scope) => $scopeLabels[$scope->scope->value.':'.$scope->uuid] ?? null)->filter())
->join(' ')),
])->values()->all();
}