Skip to content

Commit a99036c

Browse files
authored
Fix empty guard alert blocks in Workflow Health Dashboard issue output (#27202)
1 parent 31f022a commit a99036c

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

actions/setup/js/firewall_blocked_domains.cjs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ function generateBlockedDomainsSection(blockedDomains) {
196196
const domainWord = domainCount === 1 ? "domain" : "domains";
197197

198198
let section = "\n\n> [!WARNING]\n";
199-
section += `> <details>\n`;
200-
section += `> <summary><strong>⚠️ Firewall blocked ${domainCount} ${domainWord}</strong></summary>\n`;
199+
section += `> **⚠️ Firewall blocked ${domainCount} ${domainWord}**\n`;
201200
section += `>\n`;
202201
section += `> The following ${domainWord} ${domainCount === 1 ? "was" : "were"} blocked by the firewall during workflow execution:\n`;
203202
section += `>\n`;
@@ -220,8 +219,6 @@ function generateBlockedDomainsSection(blockedDomains) {
220219
section += `> \`\`\`\n`;
221220
section += `>\n`;
222221
section += `> See [Network Configuration](https://github.github.com/gh-aw/reference/network/) for more information.\n`;
223-
section += `>\n`;
224-
section += `> </details>\n`;
225222

226223
return section;
227224
}

actions/setup/js/firewall_blocked_domains.test.cjs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,27 +305,23 @@ describe("firewall_blocked_domains.cjs", () => {
305305
expect(generateBlockedDomainsSection(undefined)).toBe("");
306306
});
307307

308-
it("should generate details section for single blocked domain", () => {
308+
it("should generate warning section for single blocked domain", () => {
309309
const result = generateBlockedDomainsSection(["blocked.example.com"]);
310310

311311
expect(result).toContain("> [!WARNING]");
312-
expect(result).toContain("> <details>");
313-
expect(result).toContain("> </details>");
314-
expect(result).toContain("> <summary><strong>⚠️ Firewall blocked 1 domain</strong></summary>");
312+
expect(result).toContain("> **⚠️ Firewall blocked 1 domain**");
315313
expect(result).toContain("> - `blocked.example.com`");
316314
expect(result).toContain("> The following domain was blocked by the firewall during workflow execution:");
317315
expect(result).toContain('> ```yaml\n> network:\n> allowed:\n> - defaults\n> - "blocked.example.com"\n> ```');
318316
expect(result).toContain("> See [Network Configuration](https://github.github.com/gh-aw/reference/network/) for more information.");
319317
});
320318

321-
it("should generate details section for multiple blocked domains", () => {
319+
it("should generate warning section for multiple blocked domains", () => {
322320
const domains = ["alpha.example.com", "beta.example.com", "gamma.example.com"];
323321
const result = generateBlockedDomainsSection(domains);
324322

325323
expect(result).toContain("> [!WARNING]");
326-
expect(result).toContain("> <details>");
327-
expect(result).toContain("> </details>");
328-
expect(result).toContain("> <summary><strong>⚠️ Firewall blocked 3 domains</strong></summary>");
324+
expect(result).toContain("> **⚠️ Firewall blocked 3 domains**");
329325
expect(result).toContain("> - `alpha.example.com`");
330326
expect(result).toContain("> - `beta.example.com`");
331327
expect(result).toContain("> - `gamma.example.com`");

actions/setup/js/gateway_difc_filtered.cjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ function generateDifcFilteredSection(filteredEvents) {
9191

9292
const count = uniqueEvents.length;
9393
const itemWord = count === 1 ? "item" : "items";
94+
const verb = count === 1 ? "was" : "were";
95+
const subjectNegationPhrase = count === 1 ? "it doesn't" : "they don't";
9496

9597
let section = "\n\n> [!NOTE]\n";
9698
section += `> <details>\n`;
9799
section += `> <summary>🔒 Integrity filter blocked ${count} ${itemWord}</summary>\n`;
98100
section += `>\n`;
99-
section += `> The following ${itemWord} were blocked because they don't meet the GitHub integrity level.\n`;
101+
section += `> The following ${itemWord} ${verb} blocked because ${subjectNegationPhrase} meet the GitHub integrity level.\n`;
100102
section += `>\n`;
101103

102104
const maxItems = 16;

actions/setup/js/gateway_difc_filtered.test.cjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ describe("gateway_difc_filtered.cjs", () => {
259259
const events = [{ type: "DIFC_FILTERED", tool_name: "tool", reason: "reason" }];
260260
const result = generateDifcFilteredSection(events);
261261

262-
expect(result).toContain("blocked because they don't meet");
262+
expect(result).toContain("blocked because it doesn't meet");
263263
expect(result).toContain("GitHub integrity level");
264264
});
265265

@@ -300,13 +300,15 @@ describe("gateway_difc_filtered.cjs", () => {
300300
const singleResult = generateDifcFilteredSection(singleEvent);
301301
expect(singleResult).toContain("1 item");
302302
expect(singleResult).not.toContain("items");
303+
expect(singleResult).toContain("blocked because it doesn't meet");
303304

304305
const multiEvents = [
305306
{ type: "DIFC_FILTERED", tool_name: "tool1", reason: "r1" },
306307
{ type: "DIFC_FILTERED", tool_name: "tool2", reason: "r2" },
307308
];
308309
const multiResult = generateDifcFilteredSection(multiEvents);
309310
expect(multiResult).toContain("2 items");
311+
expect(multiResult).toContain("blocked because they don't meet");
310312
});
311313

312314
it("should deduplicate filtered events with identical fields", () => {

0 commit comments

Comments
 (0)