Skip to content

Database Orphan Bug: Model name permanently locked if JSON file save fails (OSError) #97

@jhaayushkumar

Description

@jhaayushkumar

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:

  1. Revoke write permissions on templates/json-model/.
  2. Save a valid model in the UI.
  3. See error "Model validated but failed to save" (Status 400).
  4. Try saving the model again with the same name.
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions