Skip to content

Add helper method to ensure benchmark folder existency#2011

Open
ravikiranvm wants to merge 3 commits intomainfrom
ops-3752
Open

Add helper method to ensure benchmark folder existency#2011
ravikiranvm wants to merge 3 commits intomainfrom
ops-3752

Conversation

@ravikiranvm
Copy link
Contributor

@ravikiranvm ravikiranvm commented Feb 25, 2026

Fixes OPS-3752

Additional Notes

This PR implements minimal service for create benchmark endpoint that ensures Benchmark folder exists for a given provider.

@linear
Copy link

linear bot commented Feb 25, 2026

@ravikiranvm ravikiranvm marked this pull request as ready for review February 25, 2026 11:25
Copilot AI review requested due to automatic review settings February 25, 2026 11:25
@ravikiranvm ravikiranvm changed the title Add helper method to ensure benchmark folder Add helper method to ensure benchmark folder existency Feb 25, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a small benchmark service layer to ensure a provider-specific benchmark folder exists (creating it if necessary), and introduces unit tests for the new behavior. This fits into the existing benchmark feature area alongside the wizard/provider adapters.

Changes:

  • Added getBenchmarkFolderDisplayName, ensureBenchmarkFolder, and createBenchmark in the benchmark service layer.
  • Added unit tests covering provider display name resolution, folder ensure behavior, and basic createBenchmark response shape.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/server/api/src/app/benchmark/create-benchmark.service.ts Introduces helper(s) to resolve benchmark folder name, ensure the folder exists via flowFolderService, and build a CreateBenchmarkResponse.
packages/server/api/test/unit/benchmark/create-benchmark.service.test.ts Adds unit coverage for provider handling and folder creation/reuse behavior via mocked flowFolderService.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud
Copy link

Comment on lines +27 to +39
let existingFolder =
await flowFolderService.getOneByDisplayNameCaseInsensitive({
projectId,
displayName,
contentType: ContentType.WORKFLOW,
});

if (existingFolder) {
return flowFolderService.getOneOrThrow({
projectId,
folderId: existingFolder.id,
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, this was my thought.
We might not re-create benchmark folder once it was created. So I thought instead of catching error on every call, I thought we first check for existence and then try to create if not already created.

Anyways I might be wrong; I will change it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is being done in the create method. There is no need to make two database calls to check the same behaviour.

 async create(params: UpsertParams): Promise<FolderDto> {
    const { projectId, request } = params;
    const requestContentType = request.contentType ?? ContentType.WORKFLOW;
    const folderWithDisplayName = await this.getOneByDisplayNameCaseInsensitive(
      {
        projectId,
        displayName: request.displayName,
        contentType: requestContentType,
      },
    );
    if (!isNil(folderWithDisplayName)) {
      throw new ApplicationError({
        code: ErrorCode.FOLDER_ALREADY_EXISTS,
        params: { folderName: request.displayName },
      });
    }

Comment on lines +54 to +59
existingFolder =
await flowFolderService.getOneByDisplayNameCaseInsensitive({
projectId,
displayName,
contentType: ContentType.WORKFLOW,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The create method already does this call. So, if you are here, with this exception you just need to call getOneOrThrow.

Copy link
Contributor Author

@ravikiranvm ravikiranvm Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch I get it now :'(

async create(params: UpsertParams): Promise<FolderDto> {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants