Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Preserve copied-evidence boundaries when reading feedback fields

pulse-triage[bot]a54948c574aa
diff --git a/.github/scripts/issue-version-triage.cjs b/.github/scripts/issue-version-triage.cjs
index 95a860cb60..12900f1d56 100644
--- a/.github/scripts/issue-version-triage.cjs
+++ b/.github/scripts/issue-version-triage.cjs
@@ -185,7 +185,7 @@ function firstFieldValue(lines, start = 0) {
return "";
}
-function extractSectionValues(body, heading, followingHeadings = [], report = parseReportMarkdown(body)) {
+function extractSectionValues(body, heading, followingHeadings = [], report = parseReportMarkdown(body), declarationsOnly = false) {
if (!body) return [];
const lines = report.lines;
const pattern = new RegExp(`^${escapeRegExp(heading)}$`, "i");
@@ -200,7 +200,8 @@ function extractSectionValues(body, heading, followingHeadings = [], report = pa
boundary.test(lines[end].heading))))) {
end += 1;
}
- values.push(lines.slice(start + 1, end).map((line) => line.text).join("\n").trim());
+ values.push(lines.slice(start + 1, end).map((line) =>
+ !declarationsOnly || line.declaration ? line.text : "").join("\n").trim());
// A deeper, form-named subheading is part of this value, not another
// declaration. Only resume at the boundary that ended the field.
start = end - 1;
@@ -433,7 +434,9 @@ function classifyFeedbackSelection(feedbackType, report) {
}
function classifyV6FeedbackType(body, report = parseReportMarkdown(body)) {
- const classes = extractSectionValues(body, "Feedback type", [], report)
+ // Preserve the report's original block context. Re-lexing copied code or a
+ // quote as bare field text could let examples supply or veto a selection.
+ const classes = extractSectionValues(body, "Feedback type", [], report, true)
.map(value => classifyFeedbackSelection(value, report));
// Repeated declarations must agree on the metadata category. Choosing the
// first can invent a bug and its version requirements from contradictory or
diff --git a/.github/scripts/issue-version-triage.test.cjs b/.github/scripts/issue-version-triage.test.cjs
index 3563df5b06..13e7898008 100644
--- a/.github/scripts/issue-version-triage.test.cjs
+++ b/.github/scripts/issue-version-triage.test.cjs
@@ -498,8 +498,6 @@ test("feedback classification examines the complete field instead of its first l
"Documentation issue\nBug / regression",
"Bug / regression\nThis is a question, not a selected form option.",
"Documentation issue\n\nBug / regression",
- "Bug / regression\n\n> Documentation issue",
- "Bug / regression\n\n```text\nDocumentation issue\n```",
"Bug / regression\n\n![context](https://example.invalid/synthetic.png)",
"Bug / regression\n\n- Documentation issue",
]) {
@@ -526,6 +524,26 @@ test("a complete single choice retains wrapping, hidden comments and shared refe
}
});
+test("copied blocks cannot supply or contradict a feedback selection", () => {
+ for (const copied of [
+ "> Documentation issue",
+ "```text\nDocumentation issue\n```",
+ " Documentation issue",
+ "<div>Documentation issue</div>",
+ ]) {
+ for (const newline of ["\n", "\r\n"]) {
+ for (const selection of [`Bug / regression\n\n${copied}`, `${copied}\n\nBug / regression`]) {
+ const body = `### Feedback type\n${selection}\n\n### Pulse version\nunknown`
+ .replaceAll("\n", newline);
+ assert.equal(triage.internals.classifyV6FeedbackType(body), "bug", selection);
+ }
+ const body = `### Feedback type\n${copied}\n\n### Pulse version\nunknown`
+ .replaceAll("\n", newline);
+ assert.equal(triage.internals.classifyV6FeedbackType(body), null, copied);
+ }
+ }
+});
+
for (const action of ["opened", "edited", "reopened"]) {
test(`${action} ambiguous field content cannot invent labels or lose independent topic review`, async () => {
for (const alreadyBug of [false, true]) {