From 7ec5bef6180a38dbbc8cdad52eace7ff8e06b06d Mon Sep 17 00:00:00 2001 From: Rohan Date: Tue, 3 Dec 2024 20:47:19 +0530 Subject: [PATCH] fix: misc fixes for backward compatibility --- backend/api/tasks.py | 2 +- backend/api/utils/syncing/vercel/main.py | 12 +++++++++--- backend/backend/graphene/mutations/syncing.py | 5 ----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/backend/api/tasks.py b/backend/api/tasks.py index a34debc36..99d3faa42 100644 --- a/backend/api/tasks.py +++ b/backend/api/tasks.py @@ -800,7 +800,7 @@ def perform_vercel_sync(environment_sync): secrets, environment_sync.authentication.id, vercel_project["id"], - vercel_team["id"], + vercel_team["id"] if vercel_team is not None else None, vercel_environment, vercel_secret_type, ) diff --git a/backend/api/utils/syncing/vercel/main.py b/backend/api/utils/syncing/vercel/main.py index 3530f65f0..7ef1f1298 100644 --- a/backend/api/utils/syncing/vercel/main.py +++ b/backend/api/utils/syncing/vercel/main.py @@ -108,7 +108,9 @@ def list_vercel_projects(credential_id): def get_existing_env_vars(token, project_id, team_id=None): """Retrieve all environment variables for a specific Vercel project.""" - url = f"{VERCEL_API_BASE_URL}/v9/projects/{project_id}/env?teamId={team_id}" + url = f"{VERCEL_API_BASE_URL}/v9/projects/{project_id}/env" + if team_id is not None: + url += f"?teamId={team_id}" response = requests.get(url, headers=get_vercel_headers(token)) if response.status_code != 200: @@ -127,7 +129,9 @@ def get_existing_env_vars(token, project_id, team_id=None): def delete_env_var(token, project_id, team_id, env_var_id): """Delete a Vercel environment variable using its ID.""" - url = f"{VERCEL_API_BASE_URL}/v9/projects/{project_id}/env/{env_var_id}?teamId={team_id}" + url = f"{VERCEL_API_BASE_URL}/v9/projects/{project_id}/env/{env_var_id}" + if team_id is not None: + url += f"?teamId={team_id}" response = requests.delete(url, headers=get_vercel_headers(token)) if response.status_code != 200: @@ -199,7 +203,9 @@ def sync_vercel_secrets( # Bulk create environment variables if payload: - url = f"{VERCEL_API_BASE_URL}/v10/projects/{project_id}/env?upsert=true&teamId={team_id}" + url = f"{VERCEL_API_BASE_URL}/v10/projects/{project_id}/env?upsert=true" + if team_id is not None: + url += f"&teamId={team_id}" response = requests.post( url, headers=get_vercel_headers(token), json=payload ) diff --git a/backend/backend/graphene/mutations/syncing.py b/backend/backend/graphene/mutations/syncing.py index 8180e737f..690a3b3ab 100644 --- a/backend/backend/graphene/mutations/syncing.py +++ b/backend/backend/graphene/mutations/syncing.py @@ -27,11 +27,6 @@ class RailwayResourceInput(graphene.InputObjectType): name = graphene.String(required=True) -class VercelResourceInput(graphene.InputObjectType): - id = graphene.ID(required=True) - name = graphene.String(required=True) - - class InitEnvSync(graphene.Mutation): class Arguments: app_id = graphene.ID()