fix(vertexcover): structured parse errors + self-describing formats#356
Open
wrigjl wants to merge 1 commit into
Open
fix(vertexcover): structured parse errors + self-describing formats#356wrigjl wants to merge 1 commit into
wrigjl wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Malformed input to
VERTEXCOVERcurrently 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 — throwsProblemParseException("VERTEXCOVER", ...)on empty/whitespace input, and wraps any failure from theStringParserparse,int.Parse(K), or graph construction in aProblemParseException(preserving the underlying message). Anything that already is aProblemParseExceptionpasses through unwrapped.VCVerifier.verify— throwsCertificateParseExceptionon 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.instanceFormatandcertificateFormatso the controller's parse-error body can report the expected shape to the client.getEdges/getKhelpers and the large commented-out block inverify.ProblemParseException; malformed certificates (empty, whitespace,{}) throwCertificateParseException; and a test asserts both format strings are populated.Verification
dotnet build Redux.slnx— 0 warnings, 0 errors.dotnet test Redux.slnx— 688 passed, 0 failed.🤖 Generated with Claude Code