Skip to content

fix(site): show error on duplicate template rename attempt #15348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Nov 4, 2024

Fixes #15311.

image

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @ethanndickson and the rest of your teammates on Graphite Graphite

@ethanndickson ethanndickson marked this pull request as ready for review November 4, 2024 05:48
@ethanndickson ethanndickson force-pushed the ethan/template-dupe-error branch from 3e07a6c to 35b9beb Compare November 4, 2024 05:53
@ethanndickson ethanndickson changed the title fix(site): show error when renaming template to existing template fix(site): show error on duplicate template rename attempt Nov 4, 2024
@ethanndickson ethanndickson force-pushed the ethan/template-dupe-error branch from 35b9beb to 6755b76 Compare November 4, 2024 05:59
httpapi.InternalServerError(rw, err)
if database.IsUniqueViolation(err) {
httpapi.Write(ctx, rw, http.StatusConflict, codersdk.Response{
Message: fmt.Sprintf("Template %q already exists.", req.Name),
Copy link
Member Author

@ethanndickson ethanndickson Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely out of scope of this PR, but we should develop some centralised mapping of database violations to human readable error messages (codersdk.Response?).

@ethanndickson ethanndickson force-pushed the ethan/template-dupe-error branch from 6755b76 to e54c6a2 Compare November 4, 2024 06:16
@BrunoQuaresma
Copy link
Collaborator

@ethanndickson the PR looks good but I'm missing tests for FE and BE

@ethanndickson ethanndickson force-pushed the ethan/template-dupe-error branch from e54c6a2 to f05ef70 Compare November 5, 2024 05:34
Comment on lines +619 to +621
if !dbtestutil.WillUsePostgres() {
t.Skip("This test requires Postgres constraints")
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dbmem is getting removed in the near future, where this'll get removed too.

@ethanndickson ethanndickson force-pushed the ethan/template-dupe-error branch from f05ef70 to f277a27 Compare November 5, 2024 05:49
Copy link
Collaborator

@BrunoQuaresma BrunoQuaresma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, ty!

@ethanndickson ethanndickson merged commit 3c60dc3 into main Nov 5, 2024
30 checks passed
@ethanndickson ethanndickson deleted the ethan/template-dupe-error branch November 5, 2024 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

500 Error on Duplicate Template Name Change, No UI Error Displayed
2 participants