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.

Keep conflicting issue-version declarations ambiguous

pulse-triage[bot]0d2d276e29bc
diff --git a/.github/scripts/issue-version-triage.cjs b/.github/scripts/issue-version-triage.cjs
index 537ab49bb6..4e199384bd 100644
--- a/.github/scripts/issue-version-triage.cjs
+++ b/.github/scripts/issue-version-triage.cjs
@@ -175,9 +175,14 @@ function projectDeclarationLines(tokens) {
return lines;
}
-function firstFieldValue(lines) {
- const value = lines.find((line) => !line.delimiter && line.text.trim());
- return value ? value.text.trim() : "";
+function firstFieldValue(lines, start = 0) {
+ // Repeated declarations share the report snapshot; do not allocate a copy
+ // of its entire remaining suffix for each field.
+ for (let index = start; index < lines.length; index += 1) {
+ const line = lines[index];
+ if (!line.delimiter && line.text.trim()) return line.text.trim();
+ }
+ return "";
}
function extractSectionValues(body, heading, followingHeadings = [], report = parseReportMarkdown(body)) {
@@ -347,18 +352,30 @@ function extractTitlePulseVersion(title) {
return leading && !declaredVersionIsTransition(neutral) ? normalizeVersion(leading[1]) : null;
}
+// A repeated version field is evidence only when every declaration
+// agrees. First-wins would turn a copy, appended correction or uncertain
+// runtime into one exact release solely because of its position. Unknown or
+// incomplete declarations do not gain a value from a neighbouring copy.
+function agreedDeclaredVersion(versions) {
+ const first = versions[0];
+ return first && versions.every(version => version &&
+ version.toLowerCase() === first.toLowerCase()) ? first : null;
+}
+
function extractPulseVersion(title, body, report = parseReportMarkdown(body)) {
if (body) {
const lines = report.lines;
- const versionHeading = lines.findIndex((line) =>
- line.heading !== null && /^Pulse[ \t]+version$/i.test(line.heading)
+ const versionHeadings = lines.flatMap((line, index) =>
+ line.heading !== null && /^Pulse[ \t]+version$/i.test(line.heading) ? [index] : []
);
- if (versionHeading !== -1) {
+ if (versionHeadings.length) {
// The explicit running-version field is authoritative, even when it is
// incomplete. A title may name the old image in an upgrade report, and
// neighbouring fields may contain an unrelated agent version.
- return normalizeLegacyVersionValue(firstFieldValue(lines.slice(versionHeading + 1)), report);
+ return agreedDeclaredVersion(versionHeadings.map(index =>
+ normalizeLegacyVersionValue(firstFieldValue(lines, index + 1), report)));
}
+ const legacyVersions = [];
for (let i = 0; i < lines.length; i += 1) {
if (!lines[i].declaration) continue;
const line = (lines[i].heading ?? lines[i].metadata).replace(/\*\*|__/g, "")
@@ -377,11 +394,13 @@ function extractPulseVersion(title, body, report = parseReportMarkdown(body)) {
/^Pulse[ \t]*(?:[|-][ \t]*)?version(?:[ \t]*[:|][ \t]*|[ \t]+|$)(.*)$/i
);
const inlineValue = visibleField ? visibleField[1].trim() : "";
- if (inlineValue) return normalizeLegacyVersionValue(inlineValue, report);
// A declared value may itself be fenced; that does not turn headings
- // elsewhere in a fenced log into declarations.
- return normalizeLegacyVersionValue(firstFieldValue(lines.slice(i + 1)), report);
+ // elsewhere in a fenced log into declarations. Reconcile every real
+ // legacy declaration, just as with repeated form headings above.
+ legacyVersions.push(normalizeLegacyVersionValue(inlineValue ||
+ firstFieldValue(lines, i + 1), report));
}
+ if (legacyVersions.length) return agreedDeclaredVersion(legacyVersions);
}
return extractTitlePulseVersion(title);
diff --git a/.github/scripts/issue-version-triage.test.cjs b/.github/scripts/issue-version-triage.test.cjs
index 7e38d35ed0..584f5de046 100644
--- a/.github/scripts/issue-version-triage.test.cjs
+++ b/.github/scripts/issue-version-triage.test.cjs
@@ -4235,3 +4235,111 @@ for (const action of ["opened", "edited", "reopened"]) {
}
});
}
+
+test("repeated form versions require agreement rather than field order", () => {
+ const { extractPulseVersion } = triage.internals;
+ for (const second of ["6.7.0-beta.2", "unknown", "", "6.6.0.1"]) {
+ for (const values of [["6.6.0", second], [second, "6.6.0"]]) {
+ for (const heading of ["### Pulse version", "## **Pulse version**", "Pulse version\n-------------"]) {
+ const body = values.map(value => `${heading}\n\n${value}`).join("\n\n");
+ assert.equal(extractPulseVersion("Pulse 6.4.5 update failed", body), null, body);
+ }
+ }
+ }
+});
+
+test("matching repeated form versions retain formatting, references and attempted archives", () => {
+ const { extractPulseVersion } = triage.internals;
+ for (const version of ["6.6.0", "6.7.0-beta.2"]) {
+ for (const value of [
+ `**\`v${version}\`**`, `[v${version}][release]`,
+ `pulse-v${version}-linux-amd64.tar.gz`, `rcourtman/pulse:${version}`,
+ `\`\`\`text\n${version}\n\`\`\``,
+ ]) {
+ const body = `### Pulse version\nv${version}\n\n### Pulse version\n${value}\n\n` +
+ `[release]: https://example.invalid/6.4.5`;
+ assert.equal(extractPulseVersion("Pulse 6.4.5 update failed", body), version, body);
+ }
+ }
+ assert.equal(extractPulseVersion("Unversioned report",
+ "### Pulse version\n6.6.0-RC.6\n\n### Pulse version\n6.6.0-rc.6"), "6.6.0-RC.6");
+});
+
+test("legacy repeated versions require agreement in inline, standalone and loose list layouts", () => {
+ const { extractPulseVersion } = triage.internals;
+ for (const label of ["Pulse version: ", "**Pulse version**\n", "- **Pulse version**: ", "1. **Pulse version**: "]) {
+ for (const [second, expected] of [["v6.6.0", "6.6.0"], ["6.7.0-beta.2", null], ["unknown", null], ["6.6.0-", null]]) {
+ for (const values of [["6.6.0", second], [second, "6.6.0"]]) {
+ const body = values.map(value => `${label}${value}`).join("\n\n");
+ assert.equal(extractPulseVersion("Pulse 6.4.5 update failed", body), expected, body);
+ }
+ }
+ }
+});
+
+test("non-declarations and neighbouring versions cannot conflict with the primary field", () => {
+ const { extractPulseVersion } = triage.internals;
+ for (const copied of [
+ "```text\n### Pulse version\n6.4.5\n```",
+ "> ### Pulse version\n> 6.4.5",
+ "<pre>\nPulse version: 6.4.5\n</pre>",
+ "<!--\n### Pulse version\n6.4.5\n-->",
+ "### Agent version\n6.4.5\n### Last known working Pulse version\n6.4.5",
+ "### Additional actionable topics\nPreserve this second report.\n\nPulse version: 6.4.5\n\n#### Pulse version\n6.4.5",
+ ]) {
+ const body = `### Pulse version\n6.6.0\n\n${copied}`;
+ assert.equal(extractPulseVersion("Pulse 6.4.5 update failed", body), "6.6.0", body);
+ }
+});
+
+test("form version declarations retain precedence over legacy prose in other form fields", () => {
+ const { extractPulseVersion } = triage.internals;
+ for (const primary of ["6.6.0", "unknown"]) {
+ const body = `### Describe the bug\nPulse version: 6.4.5\n\n### Pulse version\n${primary}\n\n` +
+ `### Pulse version\n${primary}\n\n### Additional context\nPulse version: 6.5.0`;
+ assert.equal(extractPulseVersion("Pulse 6.3.0 update failed", body), primary === "unknown" ? null : primary);
+ }
+});
+
+for (const action of ["opened", "edited", "reopened"]) {
+ test(`${action} conflicting versions retire stale assertions without disturbing Community decisions`, async () => {
+ for (const field of ["### Pulse version\n", "Pulse version: ", "- **Pulse version**: "]) {
+ const preserved = ["bug", "needs-retest-on-latest", "needs-decomposition", "operator-reviewed", "affects-storage"];
+ const issue = { number: 42, state: "open", title: "Pulse 6.4.5 update failed",
+ body: `${field}6.6.0\n\n${field}6.7.0-beta.2`, comments: 1,
+ updated_at: "2026-10-29T04:34:00Z",
+ labels: [...preserved, "affects-6.5.0"].map(name => ({ name })) };
+ const { github, calls } = createGithub({ currentIssue: issue });
+ await syncLabels({ github, context: createContext({ action, issue }), core: createCore() });
+ assert.deepEqual(github.currentIssue.labels.map(label => label.name).sort(),
+ [...preserved, "needs-version-info"].sort(), field);
+ assert.deepEqual(calls.removeLabel.map(call => call.name), ["affects-6.5.0"], field);
+
+ // Resolving the ambiguity is an ordinary body edit, not a refile or a
+ // reporter contact. It can restore the exact version and retire unknown.
+ const previousBody = github.currentIssue.body;
+ github.currentIssue = { ...github.currentIssue, body: `${field}6.7.0-beta.2\n\n${field}v6.7.0-beta.2`,
+ updated_at: "2026-10-29T04:35:00Z" };
+ await syncLabels({ github,
+ context: createContext({ action: "edited", issue: github.currentIssue, previousBody }), core: createCore() });
+ assert.deepEqual(github.currentIssue.labels.map(label => label.name).sort(),
+ [...preserved, "affects-6.7.0-beta.2"].sort(), field);
+ assert.equal(calls.createComment.length, 0);
+ assert.equal(calls.getLatestRelease.length, 0);
+ assert.equal(calls.getEvents.length, 0);
+ }
+ });
+}
+
+test("version ambiguity cannot lose an independently declared topic review", async () => {
+ const issue = { number: 42, state: "open", title: "Two report declarations",
+ body: "### Pulse version\n6.6.0\n\n### Pulse version\n6.7.0-beta.2\n\n" +
+ "### Additional actionable topics\nPreserve a separate notification job.",
+ comments: 0, updated_at: "2026-10-29T04:34:00Z", labels: [{ name: "bug" }] };
+ const { github, calls } = createGithub({ currentIssue: issue });
+ await syncLabels({ github, context: createContext({ issue }), core: createCore() });
+ assert.deepEqual(github.currentIssue.labels.map(label => label.name).sort(),
+ ["bug", "needs-decomposition", "needs-version-info"]);
+ assert.equal(calls.createComment.length, 0);
+ assert.equal(calls.getLatestRelease.length, 0);
+});