Skip to content

Fix timeout leak, transcript_segments shape mismatch, and ENABLE_VERTEX_AI boolean guard#34

Merged
groupthinking merged 5 commits intomainfrom
copilot/sub-pr-33
Feb 27, 2026
Merged

Fix timeout leak, transcript_segments shape mismatch, and ENABLE_VERTEX_AI boolean guard#34
groupthinking merged 5 commits intomainfrom
copilot/sub-pr-33

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

Four bugs identified in code review of the frontend video pipeline PR.

Changes

  • Timeout never cleared on fetch error (video/route.ts, transcribe/route.ts): clearTimeout was placed after await fetch(...), so aborts and network errors left the timer pending. Replaced with .finally(() => clearTimeout(timeout)):

    const response = await fetch(url, { signal: controller.signal })
      .finally(() => clearTimeout(timeout));
  • transcript_segments always 0 (video/route.ts): Backend returns transcript as { text, source, segments }, not an array. result.transcript?.length was always undefined. Fixed to result.transcript?.segments?.length.

  • ENABLE_VERTEX_AI=0 still triggered Vertex AI import (gemini_service.py): Raw os.getenv("ENABLE_VERTEX_AI") is truthy for any non-empty string including "0". Replaced with an explicit allowlist check:

    os.getenv("ENABLE_VERTEX_AI", "").lower() in {"1", "true", "yes"}
  • Duplicate let transcript = '' (video/route.ts): Removed duplicate declaration that would cause a compile error.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link
Contributor

vercel bot commented Feb 27, 2026

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

Project Deployment Actions Updated (UTC)
v0-uvai Error Error Feb 27, 2026 11:11pm

@railway-app railway-app bot temporarily deployed to EventRelay / EventRelay-pr-34 February 27, 2026 22:34 Destroyed
@railway-app
Copy link

railway-app bot commented Feb 27, 2026

🚅 Deployed to the EventRelay-pr-34 environment in EventRelay

Service Status Web Updated (UTC)
supabase ✅ Success (View Logs) Feb 27, 2026 at 11:05 pm
web ✅ Success (View Logs) Web Feb 27, 2026 at 11:05 pm
EventRelay ✅ Success (View Logs) Web Feb 27, 2026 at 11:05 pm
guides ✅ Success (View Logs) Web Feb 27, 2026 at 11:04 pm
eslint-config ✅ Success (View Logs) Web Feb 27, 2026 at 11:04 pm

…LE_VERTEX_AI boolean parsing

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
@railway-app railway-app bot temporarily deployed to EventRelay / EventRelay-pr-34 February 27, 2026 22:38 Destroyed
Copilot AI changed the title [WIP] Add frontend-only video analysis pipeline with multi-strategy transcription Fix timeout leak, transcript_segments shape mismatch, and ENABLE_VERTEX_AI boolean guard Feb 27, 2026
Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

Using relative URLs in server-side fetch() calls causes failures in production deployments like Vercel because the URLs cannot be reliably resolved without an absolute origin.

Fix on Vercel

@railway-app railway-app bot temporarily deployed to EventRelay / EventRelay-pr-34 February 27, 2026 23:03 Destroyed
Base automatically changed from claude/slack-check-status-update-R47Ph to main February 27, 2026 23:05
@railway-app railway-app bot temporarily deployed to EventRelay / EventRelay-pr-34 February 27, 2026 23:10 Destroyed
@groupthinking groupthinking marked this pull request as ready for review February 27, 2026 23:10
@groupthinking groupthinking self-requested a review as a code owner February 27, 2026 23:10
Copilot AI review requested due to automatic review settings February 27, 2026 23:10
@groupthinking groupthinking merged commit ee6fc60 into main Feb 27, 2026
13 of 15 checks passed
@groupthinking groupthinking deleted the copilot/sub-pr-33 branch February 27, 2026 23:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to address several correctness issues in the video → transcript → analysis pipeline, including timeout cleanup, aligning transcript_segments with the backend transcript shape, and fixing env-var boolean handling for optional Vertex AI imports.

Changes:

  • Ensures abort timeouts are always cleared even when fetch() fails/aborts.
  • Fixes transcript_segments counting to match the backend’s transcript = { text, source, segments } shape.
  • Hardens the ENABLE_VERTEX_AI flag parsing so values like "0" don’t enable Vertex AI behavior.

Comment on lines +107 to +109
// Use trusted backend origin instead of deriving from potentially user-controlled request data
const origin = BACKEND_URL;

Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

origin is declared but never used, and the surrounding comment suggests the code is avoiding deriving an origin from the incoming request. As written, the route still derives baseUrl from request.url for the internal /api/transcribe and /api/extract-events calls, so this is dead code and potentially misleading. Either remove origin/the comment, or actually use a trusted, configured app origin when building those internal URLs (and rename the variable accordingly).

Suggested change
// Use trusted backend origin instead of deriving from potentially user-controlled request data
const origin = BACKEND_URL;

Copilot uses AI. Check for mistakes.
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.

3 participants