Skip to content

Refactor chart preview flow to reuse a single chart ID#479

Merged
AJaySi merged 1 commit intomainfrom
codex/refactor-preview-generation-flow
Apr 20, 2026
Merged

Refactor chart preview flow to reuse a single chart ID#479
AJaySi merged 1 commit intomainfrom
codex/refactor-preview-generation-flow

Conversation

@AJaySi
Copy link
Copy Markdown
Owner

@AJaySi AJaySi commented Apr 20, 2026

Motivation

  • Ensure the same chart_id is used end-to-end for chart preview generation, URL construction, and serving so preview lookup is deterministic and cannot fail due to mismatched IDs.
  • Avoid generating different internal IDs in the service and the API handler which caused inconsistent preview URLs and retrieval errors.

Description

  • Generate the chart_id once in the preview handler and pass it into BrollService.generate_chart_preview(...) so the service writes the file with the same ID. (backend/api/podcast/handlers/broll.py).
  • Add deterministic helpers get_chart_preview_filename() and get_chart_preview_path() to BrollService, and make generate_chart_preview(...) accept an optional chart_id to allow controlled filenames. (backend/services/podcast/broll_service.py).
  • Construct the preview URL using the returned file basename while retaining the shared chart_id, and validate the incoming filename in serve_chart_preview() by comparing it to get_chart_preview_filename(chart_id) before serving. (backend/api/podcast/handlers/broll.py).

Testing

  • Ran python -m py_compile backend/api/podcast/handlers/broll.py backend/services/podcast/broll_service.py which completed successfully.

Codex Task

@AJaySi AJaySi merged commit 7aead3a into main Apr 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant