Skip to content

Turn any AI agent into an AI Scientist. The #1 Agent Skills library for science, used by 250,000+ scientists worldwide. 177 ready-to-use validated skills plus 100+ scientific databases covering biology, chemistry, medicine, and drug discovery. Compatible with Cursor, Claude Code, Codex, Pi, Antigravity, and the open Agent Skills standard.

fix(analytical-method-validation): reject surplus CSV fields

Timothy Kassisaa57b2d5f5b8
diff --git a/skills/analytical-method-validation/SKILL.md b/skills/analytical-method-validation/SKILL.md
index 39d8b38f..6d193f01 100644
--- a/skills/analytical-method-validation/SKILL.md
+++ b/skills/analytical-method-validation/SKILL.md
@@ -5,7 +5,7 @@ license: MIT
compatibility: Requires Python 3.11+. Scripts use only the standard library - no numpy, scipy, or network access. Statistical distributions are computed from first principles so results are reproducible in any conforming interpreter.
allowed-tools: Read Write Edit Bash
metadata:
- version: "1.2"
+ version: "1.3"
skill-author: K-Dense Inc.
last-reviewed: "2026-07-27"
---
diff --git a/skills/analytical-method-validation/scripts/_common.py b/skills/analytical-method-validation/scripts/_common.py
index 50332f25..eb2feaeb 100644
--- a/skills/analytical-method-validation/scripts/_common.py
+++ b/skills/analytical-method-validation/scripts/_common.py
@@ -843,6 +843,11 @@ def parse_rows(text: str, path_hint: str | None = None) -> list[dict[str, str]]:
for i, row in enumerate(reader):
if i >= MAX_ROWS:
raise InputError(f"more than {MAX_ROWS} rows")
+ # DictReader stores surplus fields as a list under its None restkey.
+ if None in row:
+ raise InputError(
+ f"row {i + 1}: more fields than the header ({len(row[None])} extra)"
+ )
rows.append({(k or "").strip(): (v or "").strip() for k, v in row.items()})
if not rows:
raise InputError("no data rows found")
diff --git a/tests/analytical-method-validation/test_scripts.py b/tests/analytical-method-validation/test_scripts.py
index 262f8ae9..daa0ba9e 100644
--- a/tests/analytical-method-validation/test_scripts.py
+++ b/tests/analytical-method-validation/test_scripts.py
@@ -908,6 +908,31 @@ class TestInputHandling(unittest.TestCase):
self.assertEqual(res.returncode, 2)
self.assertIn("not numeric", res.stderr)
+ def test_ragged_csv_and_tsv_name_the_data_row(self):
+ for delimiter, suffix in ((",", ".csv"), ("\t", ".tsv")):
+ with self.subTest(suffix=suffix):
+ text = delimiter.join(("level", "response")) + "\n"
+ text += delimiter.join(("50", "10100")) + "\n"
+ text += delimiter.join(("100", "20100", "extra")) + "\n"
+ with self.assertRaisesRegex(
+ common.InputError, "row 2: more fields than the header"
+ ):
+ common.parse_rows(text, path_hint="calibration" + suffix)
+
+ def test_ragged_and_short_rows_are_cli_input_errors(self):
+ for row, message in (("100,20100,extra", "more fields than the header"),
+ ("100", "not numeric")):
+ with self.subTest(row=row):
+ res = subprocess.run(
+ [sys.executable, str(SCRIPTS_DIR / "check_response.py"), "-i", "-"],
+ input="level,response\n50,10100\n" + row + "\n",
+ capture_output=True, text=True, check=False,
+ )
+ self.assertEqual(res.returncode, 2, res.stderr)
+ self.assertIn(message, res.stderr)
+ self.assertNotIn("Traceback", res.stderr)
+ self.assertEqual(res.stdout, "")
+
def test_missing_file_exits_2(self):
res = run_script("check_response", "-i", str(FIXTURES / "does_not_exist.csv"))
self.assertEqual(res.returncode, 2)