Skip to content

Improve well-inventory CLI feedback and validation handling; add real-user CSV feature coverage#521

Merged
jirhiker merged 29 commits intostagingfrom
well-inventory-csv-fix
Feb 16, 2026
Merged

Improve well-inventory CLI feedback and validation handling; add real-user CSV feature coverage#521
jirhiker merged 29 commits intostagingfrom
well-inventory-csv-fix

Conversation

@jirhiker
Copy link
Copy Markdown
Member

@jirhiker jirhiker commented Feb 15, 2026

Summary

This PR improves the well-inventory-csv CLI 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-core to remove the FastAPIPaginationWarning compatibility warning.

Changes

1. CLI output improvements (well-inventory-csv)

  • Enhanced user-facing CLI output in cli/cli.py:
    • status banner (SUCCESS vs COMPLETED WITH ISSUES)
    • structured summary section
    • grouped validation errors by row
    • higher validation display limit (up to 10)
    • styled validation field labels (orange + bold)
    • clearer section separators and headings
  • Preserved summary compatibility line:
    • Summary: processed=... imported=... rows_with_issues=...
  • Command exits with the adapter’s actual exit code.

2. Validation crash fixes

  • schemas/__init__.py
    • past_or_today_validator now safely handles None for optional date fields.
  • schemas/well_inventory.py
    • phone_validator now catches NumberParseException and raises ValueError so invalid phone values are returned as structured row validation errors instead of crashing.

3. Real-user CSV feature test coverage

  • Added new feature:
    • tests/features/well-inventory-real-user-csv.feature
  • Added supporting steps:
    • tests/features/steps/well-inventory-real-user-csv.py
    • updates in tests/features/steps/well-inventory-csv-given.py
  • Added feature fixture copy:
    • tests/features/data/well-inventory-real-user-entered-data.csv

4. Dependency updates (warning fix)

  • Updated:
    • pydantic==2.12.5
    • pydantic-core==2.41.5
  • Files updated:
    • pyproject.toml
    • uv.lock
    • requirements.txt

5. Test updates

  • Updated tests/test_cli_commands.py assertions to match new grouped validation output format.

Why

  • Real-world CSVs are noisy; import should never crash on invalid rows.
  • CLI users need clear, row-grouped diagnostics to fix input quickly.
  • fastapi-pagination warning required aligning pydantic versions for compatibility.

Testing

  • Feature dry-run binding checks for new/updated Behave steps.
  • Mocked CliRunner checks for output/exit-code behavior in well-inventory-csv.
  • Updated CLI unit test expectations for new formatting.

Note: Full DB-backed test execution was limited in this environment due local Postgres availability constraints.

Reviewer Notes

  • This branch includes well-inventory CLI/validation/test changes.
  • Please pay special attention to:
    • output formatting in cli/cli.py
    • validation handling in schemas/well_inventory.py and schemas/__init__.py
    • behavior expectations in tests/test_cli_commands.py

Copilot AI review requested due to automatic review settings February 15, 2026 06:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Copilot AI review requested due to automatic review settings February 15, 2026 06:41
@jirhiker jirhiker review requested due to automatic review settings February 15, 2026 06:41
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 15, 2026 06:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 13 changed files in this pull request and generated 2 comments.

@DataIntegrationGroup DataIntegrationGroup deleted a comment from Copilot AI Feb 15, 2026
jirhiker and others added 2 commits February 14, 2026 23:48
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 15, 2026 06:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 12 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings February 15, 2026 07:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 15 changed files in this pull request and generated 5 comments.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 15 changed files in this pull request and generated 5 comments.

Copilot AI review requested due to automatic review settings February 15, 2026 17:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 15 changed files in this pull request and generated 5 comments.

jirhiker and others added 2 commits February 15, 2026 10:57
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 15, 2026 18:01
jirhiker and others added 3 commits February 15, 2026 11:02
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 28 out of 30 changed files in this pull request and generated 5 comments.

Copilot AI review requested due to automatic review settings February 15, 2026 18:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 28 out of 30 changed files in this pull request and generated 4 comments.

Copilot AI review requested due to automatic review settings February 16, 2026 07:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 31 out of 33 changed files in this pull request and generated 2 comments.


# Unsupported forms
assert _extract_autogen_prefix("XY-001") is None
assert _extract_autogen_prefix("XYZ-") == "XYZ-"
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
# 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-"
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@jirhiker jirhiker merged commit 6599c42 into staging Feb 16, 2026
13 checks passed
@TylerAdamMartinez TylerAdamMartinez deleted the well-inventory-csv-fix branch February 26, 2026 18:25
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