diff --git a/apps/api/src/api/config_profiles.py b/apps/api/src/api/config_profiles.py index 97d8907..08eef3b 100644 --- a/apps/api/src/api/config_profiles.py +++ b/apps/api/src/api/config_profiles.py @@ -429,7 +429,7 @@ async def update_config_profile( if field_name in ("project_id", "tool_type_id"): value = uuid.UUID(value) if value else None elif field_name == "mounts" and value is not None: - value = [m.model_dump() for m in value] + value = [m.model_dump() if not isinstance(m, dict) else m for m in value] setattr(profile, field_name, value) await session.commit() diff --git a/apps/web/src/api/sessions.ts b/apps/web/src/api/sessions.ts index 6fe0ae4..90bd206 100644 --- a/apps/web/src/api/sessions.ts +++ b/apps/web/src/api/sessions.ts @@ -71,13 +71,23 @@ export async function startInstance( projectId: string, repoId: string, instanceId: string, - configProfileId?: string + configProfileId?: string, + retries = 2 ): Promise<{ status: string; url?: string }> { - const response = await apiClient.post( - `/projects/${projectId}/repositories/${repoId}/instances/${instanceId}/start`, - { config_profile_id: configProfileId } - ); - return response.data; + try { + const response = await apiClient.post( + `/projects/${projectId}/repositories/${repoId}/instances/${instanceId}/start`, + { config_profile_id: configProfileId } + ); + return response.data; + } catch (error: any) { + // Retry on network errors (e.g. Docker creating network interfaces) + if (retries > 0 && !error.response) { + await new Promise((r) => setTimeout(r, 1500)); + return startInstance(projectId, repoId, instanceId, configProfileId, retries - 1); + } + throw error; + } } export async function stopInstance( @@ -95,13 +105,23 @@ export async function restartInstance( projectId: string, repoId: string, instanceId: string, - configProfileId?: string + configProfileId?: string, + retries = 2 ): Promise<{ status: string; url?: string }> { - const response = await apiClient.post( - `/projects/${projectId}/repositories/${repoId}/instances/${instanceId}/restart`, - { config_profile_id: configProfileId } - ); - return response.data; + try { + const response = await apiClient.post( + `/projects/${projectId}/repositories/${repoId}/instances/${instanceId}/restart`, + { config_profile_id: configProfileId } + ); + return response.data; + } catch (error: any) { + // Retry on network errors (e.g. Docker creating network interfaces) + if (retries > 0 && !error.response) { + await new Promise((r) => setTimeout(r, 1500)); + return restartInstance(projectId, repoId, instanceId, configProfileId, retries - 1); + } + throw error; + } } export async function deleteInstance(