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

Code before:
        url: `/v1/check-groups/${groupId}`
      });

      if (!res) return null;

      return {
        id: res.id.toString(),
        name: res.name,
        environmentVariables: res.environmentVariables
      };
    } catch (error) {
      if (isAxiosError(error) && error.response?.status === HttpStatusCode.NotFound) {
        return null;
      }
      throw error;
    }
  }

  async updateCheckGroupEnvironmentVariables(
    connection: TChecklyConnectionConfig,
    accountId: string,
    groupId: string,
    environmentVariables: Array<{ key: string; value: string; locked?: boolean }>
  ) {
    if (environmentVariables.length > 50) {
      throw new Error(`Checkly does not support syncing more than 50 variables to Check Group`);
    }

    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 || [];
  }

Review comment (bug):
let's throw a SecretSyncError with `shouldRetry` false so it fails fast instead of retyring:

```
throw new SecretSyncError({
      message: "Checkly does not support syncing more than 50 variables to Check Group",
      shouldRetry: false
    });
```

Code after:
        method: "GET",
        url: `/v1/check-groups/${groupId}`
      });

      if (!res) return null;

      return {
        id: res.id.toString(),
        name: res.name,
        environmentVariables: res.environmentVariables
      };
    } catch (error) {
      if (isAxiosError(error) && error.response?.status === HttpStatusCode.NotFound) {
        return null;
      }
      throw error;
    }
  }

  async updateCheckGroupEnvironmentVariables(
    connection: TChecklyConnectionConfig,
    accountId: string,
    groupId: string,
    environmentVariables: Array<{ key: string; value: string; locked?: boolean }>
  ) {
    if (environmentVariables.length > 50) {
      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);
  }