Skip to content

Deleting a template and recreating it causes 500 errors #1582

Closed
@deansheather

Description

@deansheather

OS Information

  • OS: Linux
  • Architecture: amd64
  • coder --version: Coder v0.0.0-devel+c034e83 Wed May 18 23:15:19 UTC 2022
    c034e83

Steps to Reproduce

  1. create a template from an example like gcp-linux
  2. delete it with coder templates delete gcp-linux
  3. recreate the same template with the same name
  4. status code 500: execute transaction: insert template: pq: duplicate key value violates unique constraint "templates_organization_id_name_key"

Expected

You should be able to recreate templates

Actual

We are not clearing columns that have unique constraints, so you can't create a template with the same name twice in the same org.

Logs

Screenshot

image

Notes

In v1 we resolved this problem when we soft-deleted users by randomizing all of the unique fields (i.e. setting to a random UUID). Seems like this could be solved by renaming the template to a new UUID on deletion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiArea: HTTP API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions