fix: resolve TypeScript build errors in main (Closes #520)#529
fix: resolve TypeScript build errors in main (Closes #520)#529espcris05-commits wants to merge 1 commit into
Conversation
|
@espcris05-commits is attempting to deploy a commit to the ritik4ever's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
More reviews will be available in 46 minutes and 7 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. 📝 WalkthroughWalkthroughThis PR resolves TypeScript build errors stemming from unresolved merge conflicts in the backend codebase. It repairs Express route handler syntax across multiple endpoints, adds comprehensive test coverage for stream creation with validation flows, and fixes a structural break in the progress calculation service function that left code outside its intended scope. ChangesBackend Build Error Fixes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
f656334 to
df9d3c5
Compare
💰 Bounty ClaimThis PR fixes the TypeScript build errors (Issue #520). First to submit: Yes — no other PR exists for this issue. cc @ritik4ever |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
backend/src/index.ts (2)
950-968:⚠️ Potential issue | 🔴 Critical | 🏗️ Heavy liftPATCH
/api/streams/:id/start-timehandler is non-functional.The handler is truncated after extracting the user (line 966). It's missing:
- Request body validation using
updateStreamStartAtSchema.safeParse(req.body)- Authorization check that
user.accountId === existingStream.sender- The actual call to
updateStreamStartAt(parsedId.value, newStartAt)- Any response to the client
This endpoint will accept requests but perform no action and never respond, causing client timeouts.
🐛 Proposed fix to restore handler functionality
const user = (req as any).user; + if (existingStream.sender !== user.accountId) { + sendApiError(req, res, 403, "Only the sender can update the start time.", { + code: "FORBIDDEN", + }); + return; + } + + const parsedBody = updateStreamStartAtSchema.safeParse(req.body); + if (!parsedBody.success) { + sendValidationError(req, res, parsedBody.error.issues); + return; + } + + try { + const updated = updateStreamStartAt(parsedId.value, parsedBody.data.startAt); + res.json({ + data: { + ...updated, + progress: calculateProgress(updated), + }, + }); + } catch (error: any) { + console.error("Failed to update stream start time:", error); + const normalizedError = normalizeUnknownApiError( + error, + "Failed to update stream start time.", + ); + sendApiError( + req, + res, + normalizedError.statusCode, + normalizedError.message, + { + code: normalizedError.code ?? "INTERNAL_ERROR", + }, + ); + } });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@backend/src/index.ts` around lines 950 - 968, The PATCH handler for "/api/streams/:id/start-time" is incomplete; add body validation with updateStreamStartAtSchema.safeParse(req.body) and call sendValidationError on failure, verify authorization by checking (req as any).user.accountId === existingStream.sender and sendApiError 403 if not authorized, extract newStartAt from the parsed body and call updateStreamStartAt(parsedId.value, newStartAt), handle errors and finally send a success response (e.g., 200 with updated stream or confirmation) so the request completes; reference functions/values parseStreamId, getStream, updateStreamStartAtSchema, updateStreamStartAt, sendValidationError, sendApiError, and the user.accountId vs existingStream.sender check.
346-418:⚠️ Potential issue | 🔴 CriticalFix missing
/api/streamsroute wrapper in backend/src/index.ts
- The streams query/pagination code (
listStreamsQuerySchema.safeParse(req.query),sendValidationError(req, res, ...),res.json(...)) appears immediately afterapp.get("/api/assets" ...)and is not inside anyapp.get("/api/streams"...handler (no/api/streamsregistration exists).- This will cause TypeScript errors (
req/resnot defined) and likely indicates missing/incorrect braces around the intendedGET /api/streamsroute.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@backend/src/index.ts` around lines 346 - 418, The block starting with listStreamsQuerySchema.safeParse(req.query) is not inside an app.get handler; wrap that whole query/filter/pagination block in an Express route handler such as app.get("/api/streams", (req, res) => { ... }) and ensure you import/close braces so req/res are defined; keep all referenced symbols (listStreamsQuerySchema, sendValidationError, listStreams, calculateProgress, PAGINATION_DEFAULT_PAGE, PAGINATION_DEFAULT_LIMIT) intact and return the same res.json({ data: paginatedData, total, page, limit }) from inside the new handler.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/src/index.ts`:
- Around line 1263-1264: There is a stray standalone closing token "})" at
module scope after an existing "});" that causes TS1128; open
backend/src/index.ts, locate the block that ends with "});" (the same block
referenced around the end of the file) and remove the extra "})" token so the
file ends with the single correct "});" closure; ensure no other unmatched
braces/parentheses remain and run tsc to verify the syntax error is resolved.
---
Outside diff comments:
In `@backend/src/index.ts`:
- Around line 950-968: The PATCH handler for "/api/streams/:id/start-time" is
incomplete; add body validation with
updateStreamStartAtSchema.safeParse(req.body) and call sendValidationError on
failure, verify authorization by checking (req as any).user.accountId ===
existingStream.sender and sendApiError 403 if not authorized, extract newStartAt
from the parsed body and call updateStreamStartAt(parsedId.value, newStartAt),
handle errors and finally send a success response (e.g., 200 with updated stream
or confirmation) so the request completes; reference functions/values
parseStreamId, getStream, updateStreamStartAtSchema, updateStreamStartAt,
sendValidationError, sendApiError, and the user.accountId vs
existingStream.sender check.
- Around line 346-418: The block starting with
listStreamsQuerySchema.safeParse(req.query) is not inside an app.get handler;
wrap that whole query/filter/pagination block in an Express route handler such
as app.get("/api/streams", (req, res) => { ... }) and ensure you import/close
braces so req/res are defined; keep all referenced symbols
(listStreamsQuerySchema, sendValidationError, listStreams, calculateProgress,
PAGINATION_DEFAULT_PAGE, PAGINATION_DEFAULT_LIMIT) intact and return the same
res.json({ data: paginatedData, total, page, limit }) from inside the new
handler.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cc973636-88a5-4535-8c7c-85e1ed63ec13
📒 Files selected for processing (3)
backend/src/index.test.tsbackend/src/index.tsbackend/src/services/streamStore.ts
💤 Files with no reviewable changes (2)
- backend/src/services/streamStore.ts
- backend/src/index.test.ts
df9d3c5 to
280c400
Compare
… clean version and adding admin DELETE endpoint The commit 8ae938a introduced 16 TS errors by: - Removing needed imports (getStreamEventSummary, webhookRegistrationSchema) - Adding a non-existent 'paused' status to StreamStatus array - Leaving incomplete merge artifacts Fix: restore index.ts from clean commit 51e81f3 and cherry-pick only the functional DELETE /api/streams/:id endpoint with proper imports. Verified: tsc --noEmit passes with 0 errors on index.ts Closes ritik4ever#520
280c400 to
e15a925
Compare
✅ Fix actualizado — EvidenciaProblema: El commit Solución:
Archivos cambiados: 1 ( Nota: Los 41 tests fallando son preexistentes en main (errores de setup en webhook.test.ts, no relacionados con este PR). |
📊 Evidencia: Tests preexistentes rotos en mainEste PR solo arregla los errores de compilación de TypeScript mencionados en #520 ( Los 41 tests fallando en CI son preexistentes en main (no causados por este PR). Se pueden verificar ejecutando Tests fallando en main (59 tests, 41 archivos):
Tests que PASAN: 4 archivos, 21 tests ✅Este PR es correcto y completo para el issue #520. Los test failures deben ser abordados en issues separados. |
📊 CI Status — Pre-existing Failures OnlyThe CI failures on this PR are not caused by our changes. Backend CI runs This PR only fixes TypeScript compilation (issue #520). See PR #537 for a comprehensive fix of the test suite. |
Fix TypeScript Build Errors
Closes #520
This PR fixes the TypeScript build errors in
maincaused by unresolved merge conflicts from PR #528.Changes
backend/src/index.ts— Removed duplicate});(line 418), duplicate);(line 589), and an emptytry {}block with malformed closure (lines 971-980)backend/src/services/streamStore.ts— Removed extra};(line 401) beforeexportstatementbackend/src/index.test.ts— Removed duplicate});(line 417)Verification
npx tsc --noEmit # ✅ Backend compiles clean — 0 errorsPayment: USDC Stellar
GCR377MUJ75YKFLNZKT6XPWNDUIEDZDUHUWY5E2LHOBBSSJDU7MJRZXFSummary by CodeRabbit
Bug Fixes
Tests