Skip to content

Commit 7d98164

Browse files
authored
Remove duplicate block detection error reporting (#8011)
1 parent 8dd222f commit 7d98164

File tree

3 files changed

+5
-53
lines changed

3 files changed

+5
-53
lines changed

packages/config-yaml/src/__tests__/index.test.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ describe("E2E Scenarios", () => {
251251
);
252252

253253
const config = unrolledConfig.config;
254-
const errors = unrolledConfig.errors;
255254

256255
// The original rules array should have two items
257256
expect(config?.rules?.length).toBe(3); // Now 3 with the injected block
@@ -266,13 +265,9 @@ describe("E2E Scenarios", () => {
266265
typeof config?.rules?.[2] !== "string" &&
267266
config?.rules?.[2]?.rule === "Be humble",
268267
);
269-
270-
// Check if we receive one error that is caused by duplicate rules
271-
expect(errors?.length).toBe(1);
272-
expect(errors?.[0].message.includes("Duplicate rules detected"));
273268
});
274269

275-
it("duplicate detection should happen in the assistant config first and then the intected blocks", async () => {
270+
it("duplicate detection should happen in the assistant config first and then the injected blocks", async () => {
276271
const unrolledConfig = await unrollAssistant(
277272
{
278273
uriType: "file",
@@ -313,21 +308,6 @@ describe("E2E Scenarios", () => {
313308
expect(config?.rules?.length).toBe(1);
314309
expect(config?.prompts?.length).toBe(1);
315310
expect(config?.docs?.length).toBe(1);
316-
317-
// Check if there are 8 duplication detected
318-
expect(errors?.length).toBe(8);
319-
320-
// Beginning of the assistant config duplication check
321-
expect(
322-
errors?.[0].message.includes("Duplicate models named gpt-5 detected"),
323-
).toBe(true);
324-
// Beginning of the injected blocks duplication check
325-
expect(errors?.[4].message.includes("Duplicate rules detected")).toBe(true);
326-
expect(
327-
errors?.[6].message.includes(
328-
"Duplicate mcpServers named Browser search detected",
329-
),
330-
).toBe(true);
331311
});
332312

333313
it("should throw when a block is blocklisted", async () => {

packages/config-yaml/src/load/blockDuplicationDetector.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ export class BlockDuplicationDetector {
3636
}
3737

3838
// Check if the name is duplicated within the same blockType
39-
isDuplicated(
40-
block: any,
41-
blockType: BlockType,
42-
injectError?: (errorMsg: string) => void,
43-
): boolean {
39+
isDuplicated(block: any, blockType: BlockType): boolean {
4440
// Not checking any null or undefined object
4541
if (block === null || block === undefined) {
4642
return false;
@@ -49,25 +45,16 @@ export class BlockDuplicationDetector {
4945
switch (blockType) {
5046
case "rules":
5147
if (this.isRuleDuplicated(block)) {
52-
injectError?.(
53-
`Duplicate rules${typeof block === "string" ? "" : ` named ${block.name}`} detected. The duplicate one has been deleted for preventing unexpected behavior.`,
54-
);
5548
return true;
5649
}
5750
return false;
5851
case "context":
5952
if (this.isContextDuplicated(block)) {
60-
injectError?.(
61-
`Duplicate ${block.provider} context providers detected. The duplicate one has been deleted for preventing unexpected behavior.`,
62-
);
6353
return true;
6454
}
6555
return false;
6656
default:
6757
if (this.isCommonBlockDuplicated(block, blockType)) {
68-
injectError?.(
69-
`Duplicate ${blockType} named ${block.name} detected. The duplicate one has been deleted for preventing unexpected behavior.`,
70-
);
7158
return true;
7259
}
7360
return false;

packages/config-yaml/src/load/unroll.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,6 @@ export async function unrollBlocks(
357357
): Promise<ConfigResult<AssistantUnrolled>> {
358358
const errors: ConfigValidationError[] = [];
359359

360-
function injectDuplicationError(errorMsg: string) {
361-
errors.push({
362-
fatal: false,
363-
message: errorMsg,
364-
});
365-
}
366-
367360
const unrolledAssistant: AssistantUnrolled = {
368361
name: assistant.name,
369362
version: assistant.version,
@@ -622,20 +615,15 @@ export async function unrollBlocks(
622615
for (const sectionResult of sectionResults) {
623616
if (sectionResult.blocks) {
624617
unrolledAssistant[sectionResult.section] = sectionResult.blocks.filter(
625-
(block) =>
626-
!detector.isDuplicated(
627-
block,
628-
sectionResult.section,
629-
injectDuplicationError,
630-
),
618+
(block) => !detector.isDuplicated(block, sectionResult.section),
631619
);
632620
}
633621
}
634622

635623
// Assign rules result
636624
if (rulesResult.rules) {
637625
unrolledAssistant.rules = rulesResult.rules.filter(
638-
(rule) => !detector.isDuplicated(rule, "rules", injectDuplicationError),
626+
(rule) => !detector.isDuplicated(rule, "rules"),
639627
);
640628
}
641629

@@ -654,10 +642,7 @@ export async function unrollBlocks(
654642
key,
655643
resolvedBlock,
656644
source,
657-
).filter(
658-
(block: any) =>
659-
!detector.isDuplicated(block, blockType, injectDuplicationError),
660-
);
645+
).filter((block: any) => !detector.isDuplicated(block, blockType));
661646
unrolledAssistant[key]?.push(...filteredBlocks);
662647
}
663648

0 commit comments

Comments
 (0)