Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python

Validate FCC versions in bug reports (#1124)

Ali Khokhar3f39937ec965
diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml
index cd87e956..145078d8 100644
--- a/.github/ISSUE_TEMPLATE/bug-report.yml
+++ b/.github/ISSUE_TEMPLATE/bug-report.yml
@@ -8,8 +8,8 @@ body:
id: fcc-version
attributes:
label: FCC version
- description: Run `fcc-server --version` and enter the reported version. If FCC did not install, enter `not installed`.
- placeholder: "4.4.1 or not installed"
+ description: Run `fcc-server --version` and enter only the version number, such as `4.6.1`. If FCC did not install, enter `None`.
+ placeholder: "4.6.1 or None"
validations:
required: true
diff --git a/.github/workflows/validate-bug-report-version.yml b/.github/workflows/validate-bug-report-version.yml
new file mode 100644
index 00000000..0ffb5b51
--- /dev/null
+++ b/.github/workflows/validate-bug-report-version.yml
@@ -0,0 +1,80 @@
+name: Validate bug report version
+
+on:
+ issues:
+ types: [opened, edited]
+
+concurrency:
+ group: bug-report-version-${{ github.event.issue.number }}
+ cancel-in-progress: true
+
+permissions:
+ issues: write
+
+jobs:
+ validate:
+ if: contains(github.event.issue.labels.*.name, 'bug')
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ steps:
+ - name: Validate FCC version
+ uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
+ with:
+ script: |
+ const issue = context.payload.issue;
+ const fieldPattern = "^### FCC version\\r?\\n+\\s*([^\\r\\n]+)";
+ const versionPattern = "^(?:\\d+\\.\\d+\\.\\d+|None)$";
+ const match = (issue.body || "").match(new RegExp(fieldPattern, "m"));
+ const version = match?.[1]?.trim() || "";
+ const valid = new RegExp(versionPattern).test(version);
+ const labelName = "needs-fcc-version";
+ const marker = "<!-- fcc-version-validator -->";
+ const labels = new Set(issue.labels.map((label) => label.name));
+ const repo = context.repo;
+ const issue_number = issue.number;
+
+ if (valid) {
+ if (labels.has(labelName)) {
+ await github.rest.issues.removeLabel({
+ ...repo,
+ issue_number,
+ name: labelName,
+ });
+ }
+ return;
+ }
+
+ if (!labels.has(labelName)) {
+ try {
+ await github.rest.issues.getLabel({ ...repo, name: labelName });
+ } catch (error) {
+ if (error.status !== 404) throw error;
+ try {
+ await github.rest.issues.createLabel({
+ ...repo,
+ name: labelName,
+ color: "d4c5f9",
+ description: "FCC version must be number.number.number or None",
+ });
+ } catch (createError) {
+ if (createError.status !== 422) throw createError;
+ }
+ }
+ await github.rest.issues.addLabels({
+ ...repo,
+ issue_number,
+ labels: [labelName],
+ });
+ }
+
+ const comments = await github.paginate(
+ github.rest.issues.listComments,
+ { ...repo, issue_number, per_page: 100 },
+ );
+ if (!comments.some((comment) => comment.body?.includes(marker))) {
+ await github.rest.issues.createComment({
+ ...repo,
+ issue_number,
+ body: `${marker}\nPlease edit **FCC version** to contain only an exact \`number.number.number\` value, such as \`4.6.1\`, or \`None\`. Run \`fcc-server --version\` to find the installed version.`,
+ });
+ }
diff --git a/tests/contracts/test_issue_form_version_validation.py b/tests/contracts/test_issue_form_version_validation.py
new file mode 100644
index 00000000..6c847606
--- /dev/null
+++ b/tests/contracts/test_issue_form_version_validation.py
@@ -0,0 +1,76 @@
+import json
+import re
+from pathlib import Path
+
+import pytest
+
+BUG_FORM = Path(".github/ISSUE_TEMPLATE/bug-report.yml")
+WORKFLOW = Path(".github/workflows/validate-bug-report-version.yml")
+
+
+def _workflow_pattern(name: str) -> str:
+ workflow = WORKFLOW.read_text(encoding="utf-8")
+ match = re.search(rf"const {name} = (\"[^\"]+\");", workflow)
+ assert match is not None
+ return json.loads(match.group(1))
+
+
+def test_bug_form_requires_an_exact_version_or_none() -> None:
+ form = BUG_FORM.read_text(encoding="utf-8")
+
+ assert "Run `fcc-server --version`" in form
+ assert "enter only the version number" in form
+ assert "enter `None`" in form
+ assert 'placeholder: "4.6.1 or None"' in form
+ assert "not installed" not in form
+
+
[email protected]("value", ["0.0.0", "4.6.1", "123.45.678", "None"])
+def test_version_pattern_accepts_supported_values(value: str) -> None:
+ assert re.fullmatch(_workflow_pattern("versionPattern"), value)
+
+
+ "value",
+ [
+ "",
+ "latest",
+ "4.6",
+ "4.6.1.2",
+ "v4.6.1",
+ "4.6.x",
+ "none",
+ "free-claude-code 4.6.1",
+ ],
+)
+def test_version_pattern_rejects_ambiguous_values(value: str) -> None:
+ assert re.fullmatch(_workflow_pattern("versionPattern"), value) is None
+
+
+def test_field_pattern_extracts_the_issue_form_value() -> None:
+ body = """### FCC version
+
+4.6.1
+
+### CLI
+
+Claude Code (fcc-claude)
+"""
+
+ match = re.search(_workflow_pattern("fieldPattern"), body, flags=re.MULTILINE)
+
+ assert match is not None
+ assert match.group(1) == "4.6.1"
+
+
+def test_workflow_owns_one_idempotent_triage_state() -> None:
+ workflow = WORKFLOW.read_text(encoding="utf-8")
+
+ assert "types: [opened, edited]" in workflow
+ assert "issues: write" in workflow
+ assert "needs-fcc-version" in workflow
+ assert "<!-- fcc-version-validator -->" in workflow
+ assert "github.rest.issues.createLabel" in workflow
+ assert "github.rest.issues.addLabels" in workflow
+ assert "github.rest.issues.removeLabel" in workflow
+ assert "comments.some" in workflow