Skip to content

fix: safe JSON parsing in pipeline#2

Open
dylanworrall wants to merge 6 commits intomasterfrom
fix/safe-json-parsing
Open

fix: safe JSON parsing in pipeline#2
dylanworrall wants to merge 6 commits intomasterfrom
fix/safe-json-parsing

Conversation

@dylanworrall
Copy link
Owner

Summary

  • Wrap res.json() in process_video and publish_clip tool handlers to prevent crashes on malformed API responses
  • Wrap JSON.parse() on YouTube transcript data in transcript.ts
  • Wrap res.json() on Late.dev API responses in publisher.ts

Root cause: when YouTube returns empty subtitles or the API server returns non-JSON errors, the pipeline crashes with "Unexpected end of JSON input" (HTTP 500).

Test plan

  • Call process_video with a YouTube URL — should return error message instead of crashing
  • Call publish_clip when Late.dev is down — should return error message instead of crashing

🤖 Generated with Claude Code

gilfoyle and others added 3 commits March 8, 2026 09:32
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- server.ts: wrap res.json() in process_video and publish_clip handlers
- transcript.ts: wrap JSON.parse on YouTube subtitle data
- publisher.ts: wrap res.json() on Late.dev API responses

Prevents "Unexpected end of JSON input" crashes when external APIs
return empty or malformed responses.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@netlify
Copy link

netlify bot commented Mar 14, 2026

Deploy Preview for clipbot ready!

Name Link
🔨 Latest commit 5d67e6d
🔍 Latest deploy log https://app.netlify.com/projects/clipbot/deploys/69b7250afc27e1000834afaa
😎 Deploy Preview https://deploy-preview-2--clipbot.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

gilfoyle and others added 3 commits March 14, 2026 12:24
The process_video tool was calling http://localhost:3000/api/runs which
requires the Next.js dev server to be running. Now the http-server
imports run-store and pipeline-worker directly to spawn the pipeline
without needing Next.js.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…xt.js

Both tools now call pipeline-worker, run-store, and Late.dev API directly
instead of fetching localhost:3000 API routes. The http-server is now a
thin passthrough since all logic lives in the tool execute functions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The old description "Download, analyze, clip, and optionally publish"
didn't clearly signal this is the tool for creating clips. Gemini was
hallucinating tool names like "create_clip_pipeline" instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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