open-notebook/api/routers
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
..
__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.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
commands.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
config.py fix: set version cache to 24hrs 2025-10-19 18:05:04 -03:00
context.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
embedding.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
embedding_rebuild.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
episode_profiles.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
insights.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
models.py refactor: optimize duplicate model validation and improve error handling (#219) 2025-10-25 08:48:18 -03:00
notebooks.py feat: add ability to link existing sources to notebooks (OSS-311) (#177) 2025-10-19 17:52:14 -03:00
notes.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
podcasts.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
search.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
settings.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
source_chat.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
sources.py feat: add ability to link existing sources to notebooks (OSS-311) (#177) 2025-10-19 17:52:14 -03:00
speaker_profiles.py Version 1 (#160) 2025-10-18 12:46:22 -03:00
transformations.py Version 1 (#160) 2025-10-18 12:46:22 -03:00