Repository: appwrite/appwrite
File: app/controllers/api/vcs.php (PHP)

Code before:
                        'deploymentId' => $deployment->getId(),
                        'deploymentInternalId' => $deployment->getSequence(),
                        'deploymentResourceType' => 'site',
                        'deploymentResourceId' => $resourceId,
                        'deploymentResourceInternalId' => $resourceInternalId,
                        'deploymentVcsProviderBranch' => $providerBranch,
                        'status' => 'verified',
                        'certificateId' => '',
                        'search' => implode(' ', [$ruleId, $domain]),
                        'owner' => 'Appwrite',
                        'region' => $project->getAttribute('region')
                    ]))
                );

                // VCS branch preview
                if (!empty($providerBranch)) {
                    $transformation = new Transformation([new BranchDomain()]);
                    $transformation
                        ->setInput([
                            'branch' => $providerBranch,
                            'resourceId' => $resource->getId(),
                            'projectId' => $project->getId(),
                            'sitesDomain' => $sitesDomain,
                        ])
                        ->setTraits([])
                        ->transform();
                    $domain = $transformation->getOutput();
                    $ruleId = md5($domain);
                    try {
                        $authorization->skip(
                            fn () => $dbForPlatform->createDocument('rules', new Document([
                                '$id' => $ruleId,
                                'projectId' => $project->getId(),
                                'projectInternalId' => $project->getSequence(),
                                'domain' => $domain,
                                'type' => 'deployment',
                                'trigger' => 'deployment',
                                'deploymentId' => $deployment->getId(),
                                'deploymentInternalId' => $deployment->getSequence(),
                                'deploymentResourceType' => 'site',
                                'deploymentResourceId' => $resourceId,
                                'deploymentResourceInternalId' => $resourceInternalId,
                                'deploymentVcsProviderBranch' => $providerBranch,
                                'status' => 'verified',
                                'certificateId' => '',
                                'search' => implode(' ', [$ruleId, $domain]),
                                'owner' => 'Appwrite',
                                'region' => $project->getAttribute('region')
                            ]))
                        );
                    } catch (Duplicate $err) {

Review comment (suggestion):
```suggestion
$domain =  "branch-{$branchPrefix}-{$resourceProjectHash}.{$sitesDomain}";

                    $transformation
                        ->setInput($domain)
                        ->setTraits([ maxLenght: 10, suffixLenght: 7 ])
                        ->transform();
```

Code after:
                    try {
                        $authorization->skip(
                            fn () => $dbForPlatform->createDocument('rules', new Document([
                                '$id' => $ruleId,
                                'projectId' => $project->getId(),
                                'projectInternalId' => $project->getSequence(),
                                'domain' => $domain,
                                'type' => 'deployment',
                                'trigger' => 'deployment',
                                'deploymentId' => $deployment->getId(),
                                'deploymentInternalId' => $deployment->getSequence(),
                                'deploymentResourceType' => 'site',
                                'deploymentResourceId' => $resourceId,
                                'deploymentResourceInternalId' => $resourceInternalId,
                                'deploymentVcsProviderBranch' => $providerBranch,
                                'status' => 'verified',
                                'certificateId' => '',
                                'search' => implode(' ', [$ruleId, $domain]),
                                'owner' => 'Appwrite',
                                'region' => $project->getAttribute('region')
                            ]))
                        );
                    } catch (Duplicate $err) {
                        // Ignore, rule already exists; will be updated by builds worker
                    }
                }
            }

            if ($resource->getCollection() === 'sites' && !empty($latestCommentId) && !empty($previewRuleId)) {
                $retries = 0;
                $lockAcquired = false;

                while ($retries < 9) {
                    $retries++;

                    try {
                        $dbForPlatform->createDocument('vcsCommentLocks', new Document([
                            '$id' => $latestCommentId
                        ]));
                        $lockAcquired = true;
                        break;
                    } catch (\Throwable $err) {
                        if ($retries >= 9) {
                            Console::warning("Error creating vcs comment lock for " . $latestCommentId . ": " . $err->getMessage());
                        }

                        \sleep(1);
                    }
                }

                if ($lockAcquired) {