different-ai/openwork · error · Error
Failed to update auto-import (${response.status}).
Error message
Failed to update auto-import (${response.status}). What it means
Thrown when toggling auto-import of new plugins for an integration fails with a non-2xx response. The mutation POSTs {autoImportNewPlugins} with a 15s timeout and throws getRequestError(payload, response, ...) on failure; the message is the server's error text or the fallback "Failed to update auto-import (<status>).", with 403 {error:'reauth'} upgraded to ReauthRequiredError.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_components/integration-data.tsx:1003
export function useSetConnectorInstanceAutoImport() {
const queryClient = useQueryClient();
const { runReauthableAction } = useOrgDashboard();
return useMutation({
mutationFn: async (input: { autoImportNewPlugins: boolean; connectorInstanceId: string }) => {
await runReauthableAction("set-connector-auto-import", async () => {
const { response, payload } = await requestJson(
`/v1/connector-instances/${encodeURIComponent(input.connectorInstanceId)}/auto-import`,
{
method: "POST",
body: JSON.stringify({ autoImportNewPlugins: input.autoImportNewPlugins }),
},
15000,
);
if (!response.ok) {
throw getRequestError(payload, response, `Failed to update auto-import (${response.status}).`);
}
});
return input.autoImportNewPlugins;
},
onSuccess: (_result, variables) => {
queryClient.invalidateQueries({
queryKey: integrationQueryKeys.connectorInstanceConfiguration(variables.connectorInstanceId),
});
},
});
}
export function useSyncConnectorInstanceNow() {
const queryClient = useQueryClient();
const { runReauthableAction } = useOrgDashboard();
return useMutation({View on GitHub (pinned to 2b7df46e8a)
Solutions
- Roll back the optimistic UI toggle to the prior value (variables.autoImportNewPlugins is available in onError) and surface the error.
- On 404, refresh the integration list — the instance no longer exists.
- On 403, confirm the user's role; only admins/owners can change org integration settings.
- Retry once on 5xx/network timeout before showing a persistent error.
Example fix
// before
onError: (error) => { toast(error.message); }
// after
onError: (error, variables) => {
queryClient.setQueryData(integrationQueryKeys.list(orgSlug), (old) =>
rollbackAutoImport(old, variables.connectorInstanceId, !variables.autoImportNewPlugins));
toast(error.message);
} Defensive patterns
Strategy: try-catch
Validate before calling
// before toggling
if (typeof nextValue !== "boolean") throw new Error("autoImportNewPlugins must be a boolean.");
if (!hasOrgAdminRole(userRole)) throw new Error("Only admins can change auto-import."); Type guard
function isReauthError(e: unknown): e is ReauthRequiredError {
return e instanceof ReauthRequiredError;
} Try / catch
try {
await updateAutoImportMutation.mutateAsync({ connectorInstanceId, autoImportNewPlugins: next });
} catch (error) {
queryClient.setQueryData(key, (old) => rollback(old, !next)); // undo optimistic toggle
if (isReauthError(error)) { startReauth(); return; }
showToast(error.message);
} Prevention
- Only render the toggle for users with admin/owner role.
- Always roll back the optimistic switch state in onError (variables are provided).
- Invalidate the connector list after toggle so a concurrently deleted instance disappears.
- Debounce rapid toggles to avoid racing requests.
When it happens
Trigger: PUT/POST of the auto-import setting returns non-ok: 401/403 (expired session or insufficient role — often requires admin), 404 (connector instance was removed concurrently), 422 (value not a boolean or instance not in a state that supports auto-import), 5xx, or response later than the 15000ms timeout.
Common situations: Toggling the switch on an integration whose instance was deleted in another tab; non-admin member flipping an admin-only setting; flaky network at the 15s limit; server rejects auto-import for connectors without discovery support.
Related errors
- Failed to disconnect integration (${response.status}).
- Failed to connect GitHub repository (${response.status}).
- Failed to apply GitHub discovery (${response.status}).
- Failed to sync connector instance (${response.status}).
- Failed to remove connector instance (${response.status}).
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/dbd410314d7ca028.
Report an issue: GitHub.