different-ai/openwork · error
Failed to load team access (${response.status}).
Error message
Failed to load team access (${response.status}). What it means
useTeamPluginAccess GETs /v1/teams/{teamId}/plugin-access and, when the response is not ok, throws an Error built from getErrorMessage(payload, fallback) where fallback is 'Failed to load team access (${status}).' It surfaces the server's error message when present, otherwise the HTTP status.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_components/team-access-data.tsx:122
marketplace,
role,
grantedBy,
grantedAt,
grantId,
};
}
export function useTeamPluginAccess(teamId: string) {
return useQuery({
queryKey: teamAccessQueryKeys.detail(teamId),
queryFn: async (): Promise<TeamPluginAccessItem[]> => {
const { response, payload } = await requestJson(
`/v1/teams/${encodeURIComponent(teamId)}/plugin-access`,
{ method: "GET" },
15000,
);
if (!response.ok) {
throw new Error(getErrorMessage(payload, `Failed to load team access (${response.status}).`));
}
const items = isRecord(payload) && Array.isArray(payload.items) ? payload.items : [];
return items
.map(parseTeamPluginAccessItem)
.filter((item): item is TeamPluginAccessItem => item !== null);
},
});
}
export function useRevokeTeamPluginAccess() {
const queryClient = useQueryClient();
const { runReauthableAction } = useOrgDashboard();
return useMutation({
mutationFn: async (input: { teamId: string; pluginId: string; grantId: string }) => {
await runReauthableAction("revoke-team-plugin-access", async () => {
const { response, payload } = await requestJson(View on GitHub (pinned to 2b7df46e8a)
Solutions
- Check response.status: 401 → re-authenticate / refresh the session; 403 → request team admin access; 404 → verify teamId.
- Confirm the teamId in the route/query actually exists in the current org.
- Retry after auth fix — react-query will refetch; clear cached errors.
- If 5xx persists, check Den API health/logs; the failure is server-side.
Example fix
// before
throw new Error(getErrorMessage(payload, `Failed to load team access (${response.status}).`));
// after
if (response.status === 401) { await reauthenticate(); }
throw new Error(getErrorMessage(payload, `Failed to load team access (${response.status}).`)); Defensive patterns
Strategy: retry
Validate before calling
function isValidTeamId(teamId: string): boolean {
return teamId.length > 0 && /^[%\w-]+$/.test(encodeURIComponent(teamId));
} Type guard
function isTeamAccessPayload(v: unknown): v is { items: unknown[] } {
return isRecord(v) && Array.isArray(v.items);
} Try / catch
try {
const access = await accessQuery.refetch();
} catch (e) {
const msg = e instanceof Error ? e.message : "";
const status = /\((\d{3})\)/.exec(msg)?.[1];
if (status === "401") await reauthenticate();
else if (status === "403") showNoAccessState();
else if (status?.startsWith("5")) queueRetry();
} Prevention
- Check auth state before mounting team-scoped queries
- Validate teamId against the current org before fetching
- Add retry with backoff for 5xx in the query's retry fn
When it happens
Trigger: GET team plugin-access returns 401 (unauthenticated), 403 (not a team member/admin), 404 (bad teamId), or 5xx from the Den API.
Common situations: Session expired mid-dashboard-use; user switched orgs and the teamId belongs to another org; teamId malformed in route; Den API outage or timeout returning 5xx.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Failed to load desktop policies (${response.status}).
- Could not load egress diagnostics (${response.status}).
- Egress diagnostic could not start (${response.status}).
- Failed to load inference settings (${response.status}).
- Failed to load dashboards (${response.status}).
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/c3d82944fb1736ce.
Report an issue: GitHub.