Skip to content

ProblemProvider: IActionResult + key validation on all endpoints#304

Open
wrigjl wants to merge 1 commit into
ReduxISU:CSharpAPIfrom
wrigjl:feature/problemProvider-IActionResult-validation
Open

ProblemProvider: IActionResult + key validation on all endpoints#304
wrigjl wants to merge 1 commit into
ReduxISU:CSharpAPIfrom
wrigjl:feature/problemProvider-IActionResult-validation

Conversation

@wrigjl

@wrigjl wrigjl commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add [ApiController] to ProblemProvider so missing required query params return a framework-level 400 before the method body runs — fixes the NullReferenceException and KeyNotFoundException crashes that were showing up in the console
  • Convert all string-returning endpoints (info, visualize, visualizeReduction, reduce, mapSolution, gadgets) to IActionResult for consistency with verify, solve, and problemInstance
  • Add TryGetValue guard on every endpoint so an unknown name returns { error, received } 400 instead of an unhandled exception
  • Cache the Visualization instance in visualize() instead of constructing it three times
  • Replace naked throw ArgumentException in visualizeReduction with BadRequest

Test plan

  • dotnet build API.csproj — 0 errors, same pre-existing warnings as baseline
  • dotnet test redux-tests/ — 555/555 passed

🤖 Generated with Claude Code

- Add [ApiController] so missing required query params return 400
  before the method body runs (fixes NullReferenceException and
  KeyNotFoundException crashes seen in console)
- Convert all string-returning endpoints to IActionResult
- Add TryGetValue guard on every endpoint so unknown names return
  { error, received } 400 instead of an unhandled KeyNotFoundException
- Cache Visualization instance in visualize() instead of calling
  Visualization() three times
- Replace throw ArgumentException in visualizeReduction with BadRequest

Co-Authored-By: Claude Sonnet 4.6 <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