Skip to content

fix(cli): read run-workflow-csv inputs as strings to preserve leading zeros - #174

Open
salapenar-max wants to merge 4 commits into
browser-use:mainfrom
salapenar-max:fix/run-workflow-csv-string-leading-zeros
Open

salapenar-max wants to merge 4 commits into
browser-use:mainfrom
salapenar-max:fix/run-workflow-csv-string-leading-zeros

Conversation

@salapenar-max

@salapenar-max salapenar-max commented Sep 20, 2026 •

Copy link
Copy Markdown

Problem

run-workflow-csv loads the input CSV with pd.read_csv(csv_path) (default dtype inference), and _execute_single_workflow then does str(raw_value) for a string-typed input. When pandas infers a numeric dtype, string identifiers are corrupted:

  • a zip code 01234 → int64 1234 → "1234" (leading zero lost)
  • 00089 → "89"
  • a mixed column (1002, 1002.0) → float64 → "1002.0"

The corrupted value is then substituted into the workflow's {placeholders}, so forms get filled with the wrong identifier (zip, phone, SKU, account number, …). It fails silently — no error is raised.

Fix

Read the CSV with dtype=str so string inputs keep their exact text. The existing per-field conversion still coerces number/bool inputs (float(...), truthy parse), and empty cells remain NaN, so the pd.isna(...) required-field check is unchanged.

-            df = pd.read_csv(csv_path)
+            df = pd.read_csv(csv_path, dtype=str)

Test

Adds workflows/tests/test_run_workflow_csv_string_dtype.py: string fields keep leading zeros; number/bool fields still convert; an empty required cell is still detected as missing.

Note

Prepared with AI assistance and verified locally against the current default branch.

🤖 Generated with Claude Code


Summary by cubic

Fixes run-workflow-csv silently corrupting string-typed inputs like zip codes (01234 → 1234) because pandas inferred numeric dtypes and applied default NA detection. Reads the CSV with dtype=str, keep_default_na=False, and na_values=[''] so string inputs keep exact text; number/bool fields still convert, and empty required cells are still detected as missing.

  • Literal cells like NA (country code) or null stay string text for string fields, but count as missing for number/bool fields.
  • Input-validation failures (empty required cells, conversion errors) now carry a failure_type and show in the run summary as form validation with "check CSV data" guidance, instead of KeyErroring or printing as generic failures.
  • Extracts loading and per-field conversion into workflow_use/csv_inputs.py for unit-testability; adds test_run_workflow_csv_string_dtype.py with a __main__ runner, registered in tests/run_all_tests.py.

Written for commit 1ceb716. Summary will update on new commits.

Review in cubic

… zeros

pd.read_csv() inferred numeric dtypes, so a string-typed input like a zip
code "01234" was read as int 1234 and stringified to "1234" (leading zero
lost); mixed columns became floats ("1002" -> "1002.0"). That corrupted
value is substituted into the workflow, so forms get filled with the wrong
identifier.

Read with dtype=str so string inputs keep their exact text. The per-field
type conversion still coerces number/bool inputs, and empty cells remain
NaN so required-field validation is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread workflows/cli.py Outdated
Comment thread workflows/tests/test_run_workflow_csv_string_dtype.py Outdated
Comment thread workflows/tests/test_run_workflow_csv_string_dtype.py Outdated
…rsion

Address review on browser-use#174:
- dtype=str alone still let pandas' default NA detection turn literal cells like
  "NA" (Namibia country code) or "null" into NaN. Read with keep_default_na=False
  and na_values=[''] so only empty cells are missing (pd.isna); string inputs keep
  their exact text.
- Extract the CSV load + per-field conversion into workflow_use/csv_inputs.py so
  the regression test exercises the real code, not a mirror.
- Give the test a __main__ runner and add it to tests/run_all_tests.py so the
  repo's harness actually executes it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread workflows/cli.py
Comment thread workflows/cli.py Outdated
… result

Address review round 2 on browser-use#174:
- keep_default_na=False also kept literal "NA"/"null" in numeric fields, so an
  optional numeric NA hit float() -> the conversion-failure path. Add
  is_missing(value, field_type): NA tokens are missing for number/bool fields
  (restoring pre-change behaviour) but literal text for string fields (NA = Namibia).
- Add failure_type to the input-validation failure results so the sequential
  runner's result['failure_type'] check no longer KeyErrors on them.
- Fix import order (ruff isort I001): workflow_use.csv_inputs between controller
  and healing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread workflows/cli.py
Address review round 3 on browser-use#174: the new 'input_validation' failure_type was not
taught to the run_workflow_csv summary, so empty-required-cell / bad-value rows
printed as generic 'Other failures' with no guidance. Treat input_validation like
form_validation in the breakdown label and the 'check CSV data' recommendation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant