open-notebook/api
Luis Novo a287d3b248
refactor: optimize duplicate model validation and improve error handling (#219)
* feat: prevent duplicate model names under same provider

Implement case-insensitive validation to prevent users from creating
duplicate model names under the same provider. This validation is
implemented both in the backend API and the frontend UI.

Changes:
- Backend: Add duplicate check in create_model endpoint (case-insensitive)
- Frontend: Add client-side validation in AddModelForm
- Frontend: Improve error message display from backend
- Tests: Add unit tests for duplicate model validation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor: optimize duplicate model validation and improve error handling

- Replace O(n) model iteration with efficient SurrealDB query for duplicate check
- Improve error message to include model name and provider for better UX
- Remove frontend duplicate validation (backend-only enforcement)
- Fix test authentication by setting OPEN_NOTEBOOK_PASSWORD before imports
- Update test mocking to use repo_query instead of Model.get_all()
- Add pytest fixture for TestClient to ensure proper test isolation

All 11 tests passing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* remove unnecessary package

* fix: replace any with unknown type in error handler

- Change error type from 'any' to 'unknown' to satisfy ESLint
- Add proper type assertion for error object structure
- Maintains same runtime behavior with better type safety

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-25 08:48:18 -03:00
..
routers refactor: optimize duplicate model validation and improve error handling (#219) 2025-10-25 08:48:18 -03:00
__init__.py Api podcast migration (#93) 2025-07-17 08:36:11 -03:00
auth.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
chat_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
client.py Fix/increase fix: increase API client timeouts for transformation operations timeouts (#170) 2025-10-19 11:37:24 -03:00
command_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
context_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
embedding_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
episode_profiles_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
insights_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
main.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
models.py feat: add ability to link existing sources to notebooks (OSS-311) (#177) 2025-10-19 17:52:14 -03:00
models_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
notebook_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
notes_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
podcast_api_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
podcast_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
search_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
settings_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
sources_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
transformations_service.py Version 1 (#160) 2025-10-18 12:46:22 -03:00