chore: post-hackathon cleanup — security, robustness, docs, polish#22
Merged
Conversation
Audit-driven cleanup covering security, robustness, docs, and polish.
Findings came from three parallel reviews (backend, frontend/UX, docs).
Critical fixes
- SSRF in /api/canvas/sync: validate the iCal URL with assertSafeIcalUrl
before fetching. Rejects non-HTTPS schemes, loopback/RFC1918 hosts,
169.254.169.254, and paths that don't end in .ics.
- /api/gemini/test was unauthenticated, letting anyone drain Gemini quota.
Now requires a valid session.
- /api/profile/horario could wipe materias_inscritas before the new rows
were safely persisted. Switched to snapshot-old-IDs → insert-new →
delete-old so a failed insert leaves the user's data intact.
- EmptyInsightCard auto-generated on every mount, which caused a quiet
retry loop when generation kept failing. Now guarded with
sessionStorage so the auto-attempt only fires once per session; the
manual button still works.
- WeeklyCalendar forced horizontal scroll on mobile (min-w-[760px]).
Added a stacked per-day mobile list below md.
- Demo fixtures are now factories (buildInsightFixture /
buildEventosFixture) that emit dates relative to today, so ?demo=1
works in any week instead of only the original 2026-05-11 demo week.
Robustness
- fetchWithTimeout: shared 15s AbortController-backed fetch used by the
Google Calendar helpers so a stuck upstream can't tie up a serverless
invocation.
- Added zod schemas (lib/validation/schemas.ts) and applied them to
/api/profile/setup, /api/calendar/create, /api/canvas/sync.
- Canvas iCal: dates are now extracted in America/Monterrey and stored
with the -06:00 offset; previously UTC-based extraction shifted
deadlines forward when an event was near midnight.
- Canvas error surface is sanitized: only deliberately-thrown messages
("URL inválida", etc.) reach the client; everything else is generic.
- /api/calendar/create distinguishes 401 (token expired) vs 403 (missing
scope) vs 503 (API disabled) with targeted hints and HTTP statuses.
- /api/planes/[clave] normalizes clave to uppercase so "itc26" works.
- ApplyBlocksButton uses safe-area-inset-bottom so it doesn't sit
underneath the iOS home indicator.
Docs
- README: corrected modelo enum to "tec21" | "tec26"; added
/api/profile/horario and /api/gemini/test contracts; replaced the
(auth)/login placeholder with the real structure; expanded the lib/
tree to include pdf, scheduling, tec21, validation, fixtures.
- README + .env.example: documented NEXT_PUBLIC_DEMO_MODE.
- docs/demo/demo-script.md: rewrote the onboarding step to reflect the
PDF upload flow (no more manual materia selection).
Polish
- Gemini retry now uses jittered exponential backoff to avoid thundering
herd on quota errors, and rejects empty responses before parsing.
- GET /api/planes and /api/planes/[clave] set Cache-Control with a
5-min browser + 1-hour edge TTL since the catalog is essentially
static.
- Removed dead <CardContent /> from landing.
- Sanitized DB error responses ("DB error" → user-facing copy).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
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.
Pase de limpieza después del hackathon. 25 items aplicados desde la auditoría (críticos + robustez + docs + pulido). Excluye seguridad de infra (rotación de keys / cleanup de Vercel/Supabase) que va aparte.
Critical
Robustness
fetchWithTimeoutpara llamadas externasDocs
Polish
<CardContent />🤖 Generated with Claude Code