{"record":{"id":"98c00b754f45bf79","repo":"coollabsio/coolify","slug":"project-with-the-same-name-already-exists","errorCode":null,"errorMessage":"Project with the same name already exists.","messagePattern":"Project with the same name already exists\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"app/Livewire/Project/CloneMe.php","lineNumber":108,"sourceCode":"        $this->server = $this->servers->where('id', $server_id)->first();\n    }\n\n    public function clone(string $type)\n    {\n        try {\n            $this->authorize('create', Project::class);\n            $this->validate([\n                'selectedDestination' => 'required',\n                'newName' => ValidationPatterns::nameRules(),\n            ]);\n            $selectedDestination = find_resource_destination_for_current_team($this->selectedDestination);\n            if (! $selectedDestination) {\n                throw new \\Exception('Destination not found.');\n            }\n            if ($type === 'project') {\n                $foundProject = Project::where('name', $this->newName)->first();\n                if ($foundProject) {\n                    throw new \\Exception('Project with the same name already exists.');\n                }\n                $project = Project::create([\n                    'name' => $this->newName,\n                    'team_id' => currentTeam()->id,\n                    'description' => $this->project->description.' (clone)',\n                ]);\n                if ($this->environment->name !== 'production') {\n                    $project->environments()->create([\n                        'name' => $this->environment->name,\n                        'uuid' => new_public_id(),\n                    ]);\n                }\n                $environment = $project->environments->where('name', $this->environment->name)->first();\n            } else {\n                $foundEnv = $this->project->environments()->where('name', $this->newName)->first();\n                if ($foundEnv) {\n                    throw new \\Exception('Environment with the same name already exists.');\n                }","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/coollabsio/coolify/blob/70b9acc42467278373e00de77abb40684e25b395/app/Livewire/Project/CloneMe.php#L90-L126","documentation":"When cloning as a new project, Coolify runs Project::where('name', $newName)->first() and refuses if any project with that name exists. Note from the source that the check is global - it is not scoped to the current team - so a name used by any project on the instance (including another team's) also triggers it.","triggerScenarios":"Entering a clone name identical to an existing project's name anywhere on the instance; cloning twice with the same suggested name.","commonSituations":"Repeated clones colliding with earlier copies; multi-tenant instances where another team already took the name; default names like 'my-project-1' being common.","solutions":["Choose a different, more specific name for the clone","If the collision is with an old copy, delete or rename that project first, then retry the clone"],"exampleFix":"// before - global uniqueness check\n$foundProject = Project::where('name', $this->newName)->first();\n// after - scope the check to the current team, matching how projects are listed\n$foundProject = Project::ownedByCurrentTeam()->where('name', $this->newName)->first();","handlingStrategy":"validation","validationCode":"// check names up front so the user gets inline feedback\n$taken = Project::where('name', $newName)->exists(); // note: global, not team-scoped\nif ($taken) {\n    // suggest an available name like $newName.'-clone'","typeGuard":"function projectNameIsAvailable(string $name): bool\n{\n    return Project::where('name', $name)->doesntExist();\n}","tryCatchPattern":null,"preventionTips":["Use unique, descriptive clone names (append date or short id)","Scope name-collision checks to the current team if per-team uniqueness is the actual requirement","Clean up abandoned clones so name space does not exhaust"],"tags":["livewire","clone","project","duplicate-name"],"backgroundTag":"duplicate-name-conflict","analyzedSha":"70b9acc42467278373e00de77abb40684e25b395","analyzedAt":"2026-08-17T01:41:01.313Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}