๐Ÿ”ง v4.3: Web app deep audit โ€” 12 bugs fixed (4 critical)

#6
by gaurv007 - opened

Deep Audit of web/ โ€” 12 Bugs Found & Fixed

๐Ÿ”ด Critical Fixes

BUG 1: Gradio API endpoint names wrong (analyze/route.ts)

  • Old: /gradio_api/call/_analysis_and_index (private fn name, not exposed)
  • Fix: Added api_name="analyze" to scan_btn.click() in app.py, use /gradio_api/call/analyze

BUG 2: Compare route corrupts contract text (compare/route.ts)

  • Old: HTML-escaped < โ†’ &lt; BEFORE sending to backend for analysis
  • Fix: Removed text mutation (same bug that was already fixed in analyze/route.ts v4.1)

BUG 3: Redline route points to non-existent API (redline/route.ts)

  • Old: Fallback URL gaurv007-clauseguard-api.hf.space doesn't exist
  • Fix: Rewrote to use Gradio Space API with FastAPI as optional primary

BUG 4: Chat route uses broken Gradio endpoint (chat/route.ts)

  • Old: Called non-existent /gradio_api/call/chat which always fails
  • Fix: Removed broken Gradio fallback; route now uses FastAPI only with clear error messages

๐ŸŸก Medium Fixes

BUG 7+8: .env.example stale/missing URLs (.env.example)

  • Removed non-existent CLAUSEGUARD_API_URL default, added CLAUSEGUARD_GRADIO_URL

BUG 9: Version badge shows v4.0 (nav.tsx) โ†’ Updated to v4.3

BUG 10: PDF upload uses wrong pdf-parse API (parse-upload/route.ts)

  • Fixed to use standard pdf-parse v1 API with graceful fallback

BUG 12: Analysis not saved to DB (analyze/route.ts)

  • Added analyses table insert so history works for web app users

Gradio app.py changes

  • Added api_name="analyze" to scan_btn.click()
  • Added api_name="compare" to comp_btn.click()

Files changed

  • app.py โ€” api_name parameters for Gradio endpoints
  • web/app/api/analyze/route.ts โ€” endpoint name fix + DB save
  • web/app/api/compare/route.ts โ€” removed text corruption + endpoint fix
  • web/app/api/redline/route.ts โ€” complete rewrite for Gradio fallback
  • web/app/api/chat/route.ts โ€” removed broken Gradio fallback
  • web/app/api/parse-upload/route.ts โ€” pdf-parse API fix
  • web/components/nav.tsx โ€” version badge v4.3
  • web/.env.example โ€” corrected env vars
gaurv007 changed pull request status to open
gaurv007 changed pull request status to merged

Sign up or log in to comment