Skip to content

test(cli): cover malformed diff baseline inputs - #388

Merged
TMHSDigital merged 1 commit into
TMHSDigital:mainfrom
laozhej:codex/368-baseline-parser-tests
Nov 16, 2026
Merged

TMHSDigital merged 1 commit into
TMHSDigital:mainfrom
laozhej:codex/368-baseline-parser-tests

Conversation

@laozhej

@laozhej laozhej commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Description

Add parser coverage for truncated JSON, unterminated CSV quoting, short CSV rows, and a bad middle JSONL line. The tests require a whole-file error with no partial result set. CLI tests try each malformed file as both operands of subenum diff, requiring exit 1, no stdout and a diagnostic identifying the bad path.

Also pin UTF-8 BOM handling and the existing text-diff behavior: all named lines, including - old.example.com, enter the baseline's name set.

One correction to the issue's suggested expectation: the current CSV reader enforces the header's field count, so a one-column row is rejected before the parser's short-row branch. This PR preserves that behavior rather than silently accepting a corrupt structured file. No production behavior changes.

Related Issue

Fixes #368.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvements
  • Test updates

Checklist

  • I have read the CONTRIBUTING document
  • My code follows the code style of this project
  • I have added/updated appropriate comments to the code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)

Ethical Considerations

  • This change maintains or improves the security controls in the tool
  • This change follows the educational/legitimate security testing focus of the project
  • I have considered potential misuse cases and taken appropriate steps to prevent them

Additional Information

Validated on macOS arm64 with Go 1.26.11 and golangci-lint 2.15.0:

  • All focused parser and CLI cases pass against the existing implementation; this closes a test-coverage gap, not a newly failing runtime behavior.
  • go test -race -shuffle=on ./... passes all 21 packages with tests; make lint reports 0 issues; gofmt and git diff --check pass.
  • Parser/CLI fixtures are offline. The full suite uses local DNS/HTTP fixtures and simulations.

AI assistance: OpenAI Codex investigated the issue, added the tests, ran the checks and drafted this PR. No separate human review is claimed.

@TMHSDigital
TMHSDigital merged commit 42f8b87 into TMHSDigital:main Nov 16, 2026
17 checks passed
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.

-diff and subenum diff baseline parser: malformed input untested

2 participants