Conversation
…er validation, and add CSV feature tests
There was a problem hiding this comment.
Pull request overview
This pull request enhances the well-inventory-csv workflow by improving CLI user experience, adding validation robustness, and expanding test coverage with real-world CSV data. The changes address practical issues that arise when importing messy, user-entered CSV files.
Changes:
- Enhanced CLI output with colored summaries, grouped validation errors, and proper exit codes
- Improved phone number and date validation to handle None values and parse errors gracefully
- Added BDD feature tests using real user-entered CSV data to validate production-like inputs
- Updated pydantic (2.11.7 → 2.12.5) and pydantic-core (2.33.2 → 2.41.5) dependencies
Reviewed changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| cli/cli.py | Enhanced well_inventory_csv command with formatted output, validation error grouping, and proper exit code handling |
| schemas/init.py | Updated past_or_today_validator to handle None values for optional date fields |
| schemas/well_inventory.py | Added try-catch for NumberParseException in phone_validator to return structured validation errors |
| tests/test_cli_commands.py | Added tests for CLI output formatting and validation error reporting |
| tests/features/well-inventory-real-user-csv.feature | New BDD feature for testing real user CSV data |
| tests/features/steps/well-inventory-real-user-csv.py | Step definitions for real user CSV validation scenarios |
| tests/features/steps/well-inventory-csv-given.py | Enhanced to support real user CSV file loading |
| tests/features/environment.py | Changed hardcoded rebuild flag to use environment variable via get_bool_env |
| tests/features/data/well-inventory-real-user-entered-data.csv | Real-world CSV data with 130 rows for testing |
| tests/data/well_inventory_real_user_entered_data.csv | Duplicate of the above CSV file |
| pyproject.toml, uv.lock, requirements.txt | Updated pydantic dependency versions |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1936f9a213
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…er validation, and add CSV feature tests
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…er validation, and add CSV feature tests
…gic for well_name_point_id
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ontacts in CSV upload
|
|
||
| # Unsupported forms | ||
| assert _extract_autogen_prefix("XY-001") is None | ||
| assert _extract_autogen_prefix("XYZ-") == "XYZ-" |
There was a problem hiding this comment.
The test assertion at line 845 expects _extract_autogen_prefix("XYZ-") to return "XYZ-", but the regex AUTOGEN_PREFIX_REGEX only matches 2-3 letter prefixes. The regex pattern is r"^[A-Z]{2,3}-$" which means 2 to 3 uppercase letters followed by a hyphen. "XYZ-" has 3 letters and should match, so this test appears correct. However, it would be good to add a test case for a 4-letter prefix that should return None to verify the upper bound of the regex works as expected.
| # New supported form (2-3 uppercase letter prefixes) | ||
| assert _extract_autogen_prefix("WL-XXXX") == "WL-" | ||
| assert _extract_autogen_prefix("SAC-XXXX") == "SAC-" | ||
| assert _extract_autogen_prefix("ABC -xxxx") == "ABC-" |
There was a problem hiding this comment.
The test input "ABC -xxxx" (with a space before the hyphen) is expected to extract "ABC-" prefix. However, the AUTOGEN_TOKEN_REGEX pattern uses \s* which allows optional whitespace between the prefix and hyphen. This is actually being tested correctly, but it may be worth documenting that the function normalizes whitespace by removing it when extracting the prefix.
Summary
This PR improves the
well-inventory-csvCLI workflow by making output clearer and more actionable, hardening validation behavior for messy real-world CSV input, and adding feature coverage for a real user-entered dataset.It also updates
pydantic/pydantic-coreto remove theFastAPIPaginationWarningcompatibility warning.Changes
1. CLI output improvements (
well-inventory-csv)cli/cli.py:SUCCESSvsCOMPLETED WITH ISSUES)Summary: processed=... imported=... rows_with_issues=...2. Validation crash fixes
schemas/__init__.pypast_or_today_validatornow safely handlesNonefor optional date fields.schemas/well_inventory.pyphone_validatornow catchesNumberParseExceptionand raisesValueErrorso invalid phone values are returned as structured row validation errors instead of crashing.3. Real-user CSV feature test coverage
tests/features/well-inventory-real-user-csv.featuretests/features/steps/well-inventory-real-user-csv.pytests/features/steps/well-inventory-csv-given.pytests/features/data/well-inventory-real-user-entered-data.csv4. Dependency updates (warning fix)
pydantic==2.12.5pydantic-core==2.41.5pyproject.tomluv.lockrequirements.txt5. Test updates
tests/test_cli_commands.pyassertions to match new grouped validation output format.Why
fastapi-paginationwarning required aligning pydantic versions for compatibility.Testing
CliRunnerchecks for output/exit-code behavior inwell-inventory-csv.Reviewer Notes
cli/cli.pyschemas/well_inventory.pyandschemas/__init__.pytests/test_cli_commands.py