Skip to content

refactor: improve grade route error handling and coverage - #12

Closed
lautaropaske wants to merge 4 commits into
mainfrom
fix/grade-error-handling
Closed

lautaropaske wants to merge 4 commits into
mainfrom
fix/grade-error-handling

Conversation

@lautaropaske

Copy link
Copy Markdown
Contributor

Summary

  • normalize app-generated /api/grade failures to structured JSON while preserving the existing client fallback for upstream plain-text 413 responses
  • add direct handler coverage for /api/grade success, invalid request, invalid PDF, and unexpected error paths plus regression coverage for the resume-checker error parser
  • add a minimal Vitest alias config so the route tests can import repo aliases without adding new dependencies

Testing

  • bunx vitest run src/pages/api/grade.test.ts
  • bunx vitest run src/resume-checker/utils.test.ts
  • bunx tsc --noEmit
  • local API QA via curl for GET /api/grade?url=public/a_resume.pdf, malformed multipart POST /api/grade, and PUT /api/grade

Known issue

  • bun run build still fails because the repo currently has a React version mismatch (react@19.2.0 vs react-dom@19.2.3); this branch does not change those dependencies

lautaropaske and others added 3 commits April 15, 2026 21:56
Normalize plain-text grade failures so oversized uploads and upstream text responses surface as user-readable errors instead of JSON parse exceptions.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Add direct handler coverage for the grade route and lock the client-side fallback cases so JSON and plain-text error paths stay verifiable without new test dependencies.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Return structured JSON for app-generated grade route failures so invalid request, invalid PDF, and unexpected error paths stay machine-readable while preserving the existing upload flow.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@vercel

vercel Bot commented Apr 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
open-silver Error Error Jul 22, 2026 8:19pm

Request Review

@lautaropaske lautaropaske changed the title Improve grade route error handling and coverage refactor: improve grade route error handling and coverage Apr 16, 2026
@lautaropaske
lautaropaske marked this pull request as ready for review July 22, 2026 12:58
Wire up `bun run test` and a GitHub Actions workflow (lint, typecheck,
test) so the new grade route tests actually run somewhere.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xq4oNTbLpPej9iZv14NkJJ
@lautaropaske

Copy link
Copy Markdown
Contributor Author

Superseded by #32.

The route changes here were overtaken by a8e92c1, which does the same 4xx normalization on /api/grade and additionally returns a stable GradingError instead of e.message — this branch still leaked the underlying message on the 500 path, so rebasing it would have been a regression.

The client-side half was still a real bug on main, so #32 redoes it from current main, along with the test suite and CI workflow.

This branch had an error being deployed

1 failed deployment
Preview — 65cba9f2 Deployed Jul 22, 2026 by vercel[bot]
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