open-notebook/api
POWERFULMOVES 5621066123
fix(api): initialize file_path before try block (#497)
This PR fixes a potential UnboundLocalError in the API router
by ensuring file_path is initialized before the try block.

## Issue

In the create_source endpoint, file_path was initialized inside the
try block. If an exception occurred before this initialization,
exception handlers that reference file_path would crash with
UnboundLocalError.

## Fix

- Initialize file_path = None before the try block (line 289)
- Add explanatory comment for future maintainers
- Remove duplicate initialization inside the try block

This ensures exception handlers on line 415 can safely reference
file_path without causing runtime errors.

## Testing

- Verified exception handler path no longer crashes
- Confirmed file cleanup works correctly in error cases

Co-authored-by: POWERFULMOVES <POWERFULMOVES@users.noreply.github.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
2026-01-29 22:55:59 -03:00
..
routers fix(api): initialize file_path before try block (#497) 2026-01-29 22:55:59 -03:00
__init__.py Api podcast migration (#93) 2025-07-17 08:36:11 -03:00
auth.py Feat/localization tests docker (#371) 2026-01-15 13:51:05 -03:00
chat_service.py Feat/localization tests docker (#371) 2026-01-15 13:51:05 -03:00
CLAUDE.md docs: generate comprehensive CLAUDE.md reference documentation across codebase 2026-01-03 16:27:52 -03:00
client.py Feat/localization tests docker (#371) 2026-01-15 13:51:05 -03:00
command_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
context_service.py Feat/localization tests docker (#371) 2026-01-15 13:51:05 -03:00
embedding_service.py Feat/localization tests docker (#371) 2026-01-15 13:51:05 -03:00
episode_profiles_service.py Feat/localization tests docker (#371) 2026-01-15 13:51:05 -03:00
insights_service.py Feat/localization tests docker (#371) 2026-01-15 13:51:05 -03:00
main.py feat: add cascade deletion for notebooks with delete preview (#471) 2026-01-25 14:56:14 -03:00
models.py feat: add cascade deletion for notebooks with delete preview (#471) 2026-01-25 14:56:14 -03:00
models_service.py Feat/localization tests docker (#371) 2026-01-15 13:51:05 -03:00
notebook_service.py Feat/localization tests docker (#371) 2026-01-15 13:51:05 -03:00
notes_service.py Feat/localization tests docker (#371) 2026-01-15 13:51:05 -03:00
podcast_api_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
podcast_service.py refactor: reorganize folder structure for better maintainability 2026-01-03 14:04:27 -03:00
search_service.py Feat/localization tests docker (#371) 2026-01-15 13:51:05 -03:00
settings_service.py Feat/localization tests docker (#371) 2026-01-15 13:51:05 -03:00
sources_service.py Feat/localization tests docker (#371) 2026-01-15 13:51:05 -03:00
transformations_service.py Feat/localization tests docker (#371) 2026-01-15 13:51:05 -03:00