Describe the bug
model_validate_service saves a model to the DB but fails to rollback if writing the corresponding JSON file to disk fails (OSError). This leaves a "DB orphan" (record exists, file doesn't) and permanently locks the model name.
To Reproduce
Steps to reproduce the behavior:
- Revoke write permissions on
templates/json-model/.
- Save a valid model in the UI.
- See error "Model validated but failed to save" (Status 400).
- Try saving the model again with the same name.
- See error "Model name already used" because the DB record was never deleted.
Expected behavior
When the OSError blocks the file write, the system should instantly delete the orphaned ModelBasic DB record before returning the 400 error.
Screenshots
N/A
Environment:
- OS: macOS 14
- Browser: Chrome 120
- Node.js version: 18.20.8
- Python version: 3.13.9
Additional context
File: tensormap-backend/app/services/deep_learning.py around line 103. The except OSError: block is missing a db.delete(model) + db.commit() call.
Describe the bug
model_validate_service saves a model to the DB but fails to rollback if writing the corresponding JSON file to disk fails (
OSError). This leaves a "DB orphan" (record exists, file doesn't) and permanently locks the model name.To Reproduce
Steps to reproduce the behavior:
templates/json-model/.Expected behavior
When the
OSErrorblocks the file write, the system should instantly delete the orphaned ModelBasic DB record before returning the 400 error.Screenshots
N/A
Environment:
Additional context
File: tensormap-backend/app/services/deep_learning.py around line 103. The
except OSError:block is missing adb.delete(model)+db.commit()call.