Skip to content

fix: compare samplesheet enum values as strings in validator#396

Closed
JOhnsonKC201 wants to merge 1 commit into
anthropics:mainfrom
JOhnsonKC201:fix/sarek-validate-enum-string-compare
Closed

fix: compare samplesheet enum values as strings in validator#396
JOhnsonKC201 wants to merge 1 commit into
anthropics:mainfrom
JOhnsonKC201:fix/sarek-validate-enum-string-compare

Conversation

@JOhnsonKC201

Copy link
Copy Markdown

Problem

In bio-research/skills/nextflow-development/scripts/utils/validators.py, the enum (allowed) check in validate_samplesheet compared raw CSV cell values against the configured allow-list with a plain in:

value = row[col_name]          # from CSV -> always a string, e.g. "0"
allowed = col_config["allowed"]  # may be typed, e.g. integers [0, 1]
if value not in allowed:         # "0" not in [0, 1] -> True

CSV values are read as strings, but enum allow-lists in the pipeline configs can be typed. The sarek config (scripts/config/pipelines/sarek.yaml) declares the status column as type: integer with allowed: [0, 1]. So the membership test "0" not in [0, 1] is always True, and the validator rejected every valid sarek samplesheet with errors like:

Row 2: Invalid value '0' for 'status'. Allowed: [0, 1]

Fix

Normalize both sides to strings before comparing, so typed enums validate correctly while still rejecting genuinely invalid values:

if str(value) not in [str(a) for a in allowed]:

Minimal, one-line behavioral change plus an explanatory comment.

Repro (manual — no test harness exists for these scripts)

Using a sarek-style integer enum column (status: allowed [0, 1]) and a valid samplesheet (status = "0" / "1"):

  • Before: valid: False["Row 2: Invalid value '0' for 'status'. Allowed: [0, 1]", "Row 3: Invalid value '1' ..."]
  • After: valid: True, no errors

Negative case still works: a genuinely invalid value "2" is still rejected after the fix. python -m py_compile on the changed file passes.

CSV values are read as strings (e.g. "0") but enum allow-lists may be
typed (e.g. integers [0, 1]), so the 'in' check rejected every valid
sarek samplesheet. Normalize both sides to str before comparing.
@bryan-anthropic

Copy link
Copy Markdown
Collaborator

Thanks for your interest! This repo only accepts contributions from Anthropic team members. If you'd like to submit a plugin to the marketplace, please submit your plugin here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants