Skip to content

Commit 1a5eabc

Browse files
committed
chore: add app slug uniqueness check to coderd
1 parent fecef1e commit 1a5eabc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

coderd/provisionerdaemons.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ func insertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
756756
}
757757
snapshot.WorkspaceResources = append(snapshot.WorkspaceResources, telemetry.ConvertWorkspaceResource(resource))
758758

759+
var appSlugs = make(map[string]struct{})
759760
for _, prAgent := range protoResource.Agents {
760761
var instanceID sql.NullString
761762
if prAgent.GetInstanceId() != "" {
@@ -814,6 +815,10 @@ func insertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
814815
if !provisioner.AppSlugRegex.MatchString(slug) {
815816
return xerrors.Errorf("app slug %q does not match regex %q", slug, provisioner.AppSlugRegex.String())
816817
}
818+
if _, exists := appSlugs[slug]; exists {
819+
return xerrors.Errorf("duplicate app slug, must be unique per template: %q", slug)
820+
}
821+
appSlugs[slug] = struct{}{}
817822

818823
health := database.WorkspaceAppHealthDisabled
819824
if app.Healthcheck == nil {

0 commit comments

Comments
 (0)