Bugfix: Should generated structure be saved with slug or real MongoD...
Documentation for Sessions
🐛 Bugfix: Should generated structure be saved with slug or real MongoD...
📋 Decision Context
Question:
Should generated structure be saved with slug or real MongoDB ObjectId?
Task: Session 29.6: Fix 404 error when saving generated universe
🎯 Decision Made
Chosen:
Always use real MongoDB ObjectId from SpaceService.universes(), never use route slug
Options Considered:
- Use route slug directly
- Resolve slug to real ObjectId
- Pass both slug and ID
💭 Reasoning
The 404 error occurred because architect-canvas was passing the route slug 'newly-uni-1' directly to API calls, but backend expects MongoDB ObjectId. Route: /universe/newly-uni-1 → slug is 'newly-uni-1' → need to resolve to real ID like '676d5e8c9f7b2a3d4e5f6789'. Created getCurrentUniverseId() helper that: 1) Gets slug from route, 2) Looks up universe in SpaceService.universes(), 3) Returns real ObjectId. This pattern matches existing loadUniverseData() logic (line 556-558). API endpoints always require real ObjectId, slugs are only for routing/URLs.
📁 Files Involved
libs/libs-space/universe-architect/src/lib/components/architect-canvas/architect-canvas.component.ts
🔗 Related
- Decision ID:
dev_1767890814693_100kvnx - Session: 29
- Workspace: editor2
Auto-generated by MCP Smart Consolidation