Skip to content

fix(vertexcover): structured parse errors + self-describing formats#356

Open
wrigjl wants to merge 1 commit into
ReduxISU:CSharpAPIfrom
wrigjl:vertexcover-parse-errors
Open

fix(vertexcover): structured parse errors + self-describing formats#356
wrigjl wants to merge 1 commit into
ReduxISU:CSharpAPIfrom
wrigjl:vertexcover-parse-errors

Conversation

@wrigjl

@wrigjl wrigjl commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Malformed input to VERTEXCOVER currently escapes as an unhandled exception (parser / int.Parse / graph-construction failures), which surfaces as an HTTP 500 with a stack trace rather than a structured 400 diagnostic. This brings VERTEXCOVER in line with the parse-error pattern already used by 3SAT and friends.

Changes

  • VERTEXCOVER(string) constructor — throws ProblemParseException("VERTEXCOVER", ...) on empty/whitespace input, and wraps any failure from the StringParser parse, int.Parse(K), or graph construction in a ProblemParseException (preserving the underlying message). Anything that already is a ProblemParseException passes through unwrapped.
  • VCVerifier.verify — throws CertificateParseException on empty/whitespace certificates, on node-parse failures, and when the certificate parses to an empty/blank node list, instead of letting raw parser exceptions escape.
  • Self-describing formats — adds instanceFormat and certificateFormat so the controller's parse-error body can report the expected shape to the client.
  • Dead code removal — drops the unused getEdges/getK helpers and the large commented-out block in verify.
  • Tests — invalid instances (empty, whitespace, old colon format, bare string, non-integer K, truncated) all throw ProblemParseException; malformed certificates (empty, whitespace, {}) throw CertificateParseException; and a test asserts both format strings are populated.

Verification

  • dotnet build Redux.slnx — 0 warnings, 0 errors.
  • dotnet test Redux.slnx688 passed, 0 failed.

🤖 Generated with Claude Code

Bring VERTEXCOVER in line with the parse-error handling used elsewhere
(e.g. 3SAT) so malformed input yields a diagnostic rather than an
unhandled exception:

- VERTEXCOVER constructor throws ProblemParseException on empty input and
  wraps any parse/format failure (StringParser, int.Parse, graph build)
  so the controller layer can surface a 400 instead of a 500.
- VCVerifier throws CertificateParseException on empty/malformed
  certificates instead of letting parser exceptions escape.
- Add self-describing instanceFormat/certificateFormat so the parse-error
  body can report the expected shape.
- Remove dead code (getEdges/getK, commented-out verify logic).
- Add tests covering invalid instances, malformed certificates, and the
  presence of the format strings.

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