Bugfix: SpacesService.updateUniverse/getUniverse/deleteUniverse cras...

Documentation for Sessions

🐛 Bugfix: SpacesService.updateUniverse/getUniverse/deleteUniverse cras...

Date: 2026-03-17
Time: 16:01:12 UTC
Session: gspace1-230.2
Agent: angular
Confidence: 98%
Status: ✅ Documented


📋 Decision Context

Question:

SpacesService.updateUniverse/getUniverse/deleteUniverse crash with CastError when spaceId is a slug

Task: S230: Review and fix platform generation pipeline


🎯 Decision Made

Chosen:

Resolve spaceId to space._id ObjectId via findById/findOne conditional, then use resolved ObjectId in all subsequent Mongoose operations (findByIdAndUpdate, spaceDatabaseService calls). Applied consistently to updateUniverse, getUniverse, and deleteUniverse.

Options Considered:


💭 Reasoning

Root cause: updateUniverse lines 559-564 correctly handled slug-vs-ObjectId for the LOOKUP query, but line 596 used raw spaceId in findByIdAndUpdate() which requires ObjectId. When Vitto's DEPLOY phase calls PUT /spaces/{slug}/universes/{id}, the slug causes a CastError. This silently prevented Universe.structure[] from being persisted, which is why the studio preview never showed generated platforms. Same bug existed in getUniverse (line 637 used findById without slug check) and deleteUniverse (line 677+689).


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation