Add document platform CRUD models, service, and API endpoints#575
Conversation
…cument models and API endpoints - Updated the robosystems-client version in pyproject.toml and uv.lock files for improved functionality. - Added new fields to DocumentUploadResponse and DocumentListItem models for better metadata handling. - Introduced DocumentDetailResponse and DocumentUpdateRequest models to support detailed document operations. - Refactored document-related API endpoints to utilize PostgreSQL for document management and improved error handling.
|
@claude please review this PR |
|
Claude finished @jfrench9's task in 1m 51s —— View job PR Review: Add document platform CRUD models, service, and API endpoints
Overall this is a solid, well-structured PR. The layering (migration → model → service → router → tests) is clean and consistent with the rest of the codebase. A few issues worth addressing before merge. Bugs / Correctness1. Fragile 404 detection in status = 404 if "not found" in str(e).lower() else 422This string-match on error messages is fragile. If the message ever changes, or a different 2. Upsert path doesn't propagate When an 3. OpenSearch document ID is derived inconsistently ( In Design Concerns4. Two database sessions per write request (
5. No pagination on
6.
Minor / Style7. Untyped def _document_to_list_item(doc) -> DocumentListItem:
def _document_to_detail(doc) -> DocumentDetailResponse:Add 8. Timestamp fields use
9. Redundant The TestsTest coverage is thorough across all three layers. A couple of gaps worth noting:
Summary
The fragile error detection (#1) and two-session pattern (#4) are the ones I'd prioritize before merging. The rest are low-risk improvements that could be addressed in follow-up. |
- Removed the onupdate attribute from the updated_at column in the Document model. - Eliminated the get_by_id method from the Document class to streamline document retrieval. - Updated error handling in DocumentService to raise KeyError instead of ValueError when a document is not found. - Modified the _resolve_tier function to accept an existing session, improving session management. - Enhanced type hints in document-related functions for better clarity and type safety.
Summary
Introduces full CRUD functionality for documents within the platform, spanning the database migration, domain models, service layer, API router, and comprehensive test coverage.
Key Accomplishments
Database & Models
366a6659343d): Adds thedocumentstable to the platform database schema.models/core/document/document.py): Defines the core document entity with 190 lines of model logic, including validation and data transformations.models/api/search.pyto support document-related search parameters and responses.Service Layer
operations/documents/service.py): Implements create, read, update, delete, and list operations for documents, encapsulating all business logic and data access.API Endpoints
routers/graphs/documents.py): Significantly expanded the existing documents router (~200 lines of changes) with full CRUD endpoints, proper request/response schemas, and integration with the new service layer.Dependencies
robosystems-clientdependency from previous version to 0.2.42 to align with new document API contracts.Breaking Changes
Testing
Comprehensive test suite added across all layers:
tests/models/core/document/test_document.py): 275 lines covering document model validation, serialization, and edge cases.tests/operations/documents/test_document_service.py): 232 lines testing all CRUD operations, error handling, and business logic.tests/routers/graphs/test_documents.py): 321 lines covering endpoint behavior, authorization, input validation, and error responses.tests/conftest.pywith necessary fixtures for the new test modules.Infrastructure Considerations
robosystems-clientdependency version bump (0.2.42) requires a lock file update; ensure CI/CD pipelines pull the updated dependencies.🤖 Generated with Claude Code
Branch Info:
feature/document-platform-crudmainCo-Authored-By: Claude noreply@anthropic.com