fix: Make project creation endpoint idempotent#357
Conversation
|
Claude finished @phernandez's task —— View job PR Review: Make project creation endpoint idempotentSummaryThis PR successfully makes the Code Review Checklist✅ Code Quality & Standards
|
|
Claude finished @phernandez's task —— View job PR Review: Make project creation endpoint idempotentSummaryThis PR successfully makes the Code Review Checklist✅ Code Quality & Standards
✅ Testing & Documentation
✅ Basic Memory Architecture
✅ Security & Performance
Detailed Code AnalysisImplementation Quality (src/basic_memory/api/routers/project_router.py:196-223)Excellent improvements in the second commit:
Test Coverage (tests/api/test_project_router.py)Outstanding test coverage with 6 new tests:
Coverage: 97% on project_router (per commit message) - Excellent! Spec Document ChangesObservation: The first commit (256c851) includes ~2,800 lines of spec updates across 11 files:
These spec changes appear unrelated to the idempotent project creation fix. This is fine for internal development, but for clarity:
This doesn't block the PR but would help with git history clarity. Comparison with Previous Bot ReviewThe previous automated review (Oct 14) noted several concerns that have been fully addressed:
RecommendationsOptional Improvements
No Action RequiredThe implementation is production-ready as-is. The above are minor suggestions for future consideration. Real-World ImpactContext from commit message: This fixes issues encountered by a production tenant who experienced:
This PR directly addresses:
Conclusion✅ Approved - Ready to merge This PR successfully implements idempotent project creation with:
The implementation is well-thought-out, properly tested, and production-ready. The second commit significantly improved upon the first by adding true path validation and comprehensive error handling. Great work! 🎉 |
|
Claude finished @phernandez's task —— View job PR Review: Make project creation endpoint idempotentReviewing PR #357 against Basic Memory team checklist... Tasks
Code Review Checklist✅ Code Quality & Standards
✅ Testing & Documentation
✅ Basic Memory Architecture
|
When a user tries to create a project that already exists (e.g., using the --create-project CLI flag multiple times), return 200 OK with the existing project info instead of 400 Bad Request. This improves the user experience by making the endpoint idempotent, which is particularly useful when uploading files with the --create-project flag. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
Refines the idempotent project creation behavior and adds validation for project deletion to prevent user errors. Changes: - Project creation now properly validates path matching for true idempotency - Same name + same path: Returns 200 OK (idempotent) - Same name + different path: Returns 400 with clear error message - Project deletion now prevents removing the default project - Returns 400 with helpful error listing alternative projects - Prevents accidental deletion of the only/default project This fixes issues encountered by tenant user_01K7GCGSPZ4A63H3QA5M9AMT23 who experienced 32 errors (15 delete failures, 12 create failures) due to inadequate validation. Tests: - Added 6 new comprehensive tests for validation logic - All 24 tests pass with 97% coverage on project_router - No regressions detected Fixes #173 (tenant errors) Related: #175 (delete validation), #176 (set default validation) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
Implements the optional improvement suggested in PR review to make HTTP status codes explicit rather than implicit. Changes: - Added explicit status_code=201 to POST /projects/projects decorator - Added Response parameter to override status code for idempotent requests - Returns 201 Created for new projects, 200 OK for existing (idempotent) - Updated tests to verify correct status codes (201 vs 200) This improves API documentation clarity and follows REST best practices for idempotent operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
935e272 to
35977fe
Compare
|
Claude finished @phernandez's task —— View job PR Review: Make project creation endpoint idempotentReviewing PR #357 against Basic Memory team checklist... Tasks
Code Review Checklist✅ Code Quality & Standards
✅ Testing & Documentation
✅ Basic Memory Architecture
|
Use tempfile.TemporaryDirectory() instead of hardcoded /tmp path to fix Windows test failures. The test was failing on Windows because /tmp was converted to D:/tmp, causing path comparison to fail. Also use Path.resolve() for cross-platform path normalization in assertions. Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task —— View job PR Review: Make project creation endpoint idempotentReviewing PR #357 against Basic Memory team checklist... Tasks
Code Review Checklist✅ Code Quality & Standards
✅ Testing & Documentation
✅ Basic Memory Architecture
|
Summary
When a user tries to create a project that already exists (e.g., using the
--create-projectCLI flag multiple times), the API now returns200 OKwith the existing project info instead of400 Bad Request.Changes
add_projectendpoint inproject_router.pyto catch "already exists" errors and return success with existing project details--create-projectflagTest plan
Context
This fixes 400 errors seen in production when users upload files with
--create-projectflag on projects that already exist.🤖 Generated with Claude Code