Repository: Infisical/infisical
File: backend/src/services/app-connection/checkly/checkly-connection-public-client.ts (TypeScript)

Code before:
      value: v.value,
      locked: v.locked ?? false,
      secret: true
    }));

    const group = await this.getCheckGroup(connection, accountId, groupId);

    await this.send(connection, {
      accountId,
      method: "PUT",
      url: `/v2/check-groups/${groupId}`,
      data: { name: group?.name, environmentVariables: apiVariables }
    });

    return this.getCheckGroup(connection, accountId, groupId);
  }

  async getCheckGroupEnvironmentVariables(connection: TChecklyConnectionConfig, accountId: string, groupId: string) {
    const group = await this.getCheckGroup(connection, accountId, groupId);
    return group?.environmentVariables || [];
  }

  async upsertCheckGroupEnvironmentVariables(
    connection: TChecklyConnectionConfig,
    accountId: string,
    groupId: string,
    variables: Array<{ key: string; value: string; locked?: boolean }>
  ) {
    const existingVars = await this.getCheckGroupEnvironmentVariables(connection, accountId, groupId);
    const varMap = new Map(existingVars.map((v) => [v.key, v]));

    for (const newVar of variables) {
      varMap.set(newVar.key, {
        key: newVar.key,
        value: newVar.value,
        locked: newVar.locked ?? false
      });
    }

    return this.updateCheckGroupEnvironmentVariables(connection, accountId, groupId, Array.from(varMap.values()));
  }

  async deleteCheckGroupEnvironmentVariable(
    connection: TChecklyConnectionConfig,
    accountId: string,
    groupId: string,
    variableKey: string
  ) {
    const existingVars = await this.getCheckGroupEnvironmentVariables(connection, accountId, groupId);
    const filteredVars = existingVars.filter((v) => v.key !== variableKey);


Review comment (bug):
not sure we should use this batch function; this only let's me sync 50 variables while the individual upsert calls let's me add over 50 at the global level - I can sync 100 secrets to global scope but it fails to batch group more than 50; unless this is a check group limitation we should handle the same way as global)

Code after:
      throw new SecretSyncError({
        message: "Checkly does not support syncing more than 50 variables to Check Group",
        shouldRetry: false
      });
    }

    const apiVariables = environmentVariables.map((v) => ({
      key: v.key,
      value: v.value,
      locked: v.locked ?? false,
      secret: true
    }));

    const group = await this.getCheckGroup(connection, accountId, groupId);

    await this.send(connection, {
      accountId,
      method: "PUT",
      url: `/v2/check-groups/${groupId}`,
      data: { name: group?.name, environmentVariables: apiVariables }
    });

    return this.getCheckGroup(connection, accountId, groupId);
  }

  async getCheckGroupEnvironmentVariables(connection: TChecklyConnectionConfig, accountId: string, groupId: string) {
    const group = await this.getCheckGroup(connection, accountId, groupId);
    return group?.environmentVariables || [];
  }

  async upsertCheckGroupEnvironmentVariables(
    connection: TChecklyConnectionConfig,
    accountId: string,
    groupId: string,
    variables: Array<{ key: string; value: string; locked?: boolean }>
  ) {
    const existingVars = await this.getCheckGroupEnvironmentVariables(connection, accountId, groupId);
    const varMap = new Map(existingVars.map((v) => [v.key, v]));

    for (const newVar of variables) {
      varMap.set(newVar.key, {
        key: newVar.key,
        value: newVar.value,
        locked: newVar.locked ?? false
      });
    }

    return this.updateCheckGroupEnvironmentVariables(connection, accountId, groupId, Array.from(varMap.values()));
  }

  async deleteCheckGroupEnvironmentVariable(