Skip to content

fix(sfcompute): build instance name from RefID and environment ID - #158

Draft
jainvishesh11 wants to merge 1 commit into
mainfrom
BREV-12012/SFCompute-duplicate-name-fix
Draft

jainvishesh11 wants to merge 1 commit into
mainfrom
BREV-12012/SFCompute-duplicate-name-fix

Conversation

@jainvishesh11

Copy link
Copy Markdown

Problem

Environment creation on SFCompute v2 fails with:

status 400: {"error":{"type":"invalid_request_error","message":"an instance with this
name already exists","details":[{"field":"name","code":"duplicate"}]}}

Root Cause

SFCompute treats the instance name as a unique key per workspace, and every Brev environment on a cloud credential shares one workspace. CreateInstance sent only the sanitized user-supplied environment name, while the globally unique RefID went to tags only, which SFCompute ignores for uniqueness.

Fix

Compose the name from Brev IDs instead of the user's supplied environment name:

func makeSFCName(refID string, tags v1.Tags) string {
    return sanitizeSFCName(refID + "-" + tags["dev-plane-x-environmentId"])
}

Giving e.g. inst-2toqsvHXfalevkjPXY2QNJZL9HF-p82qfn5qs. The Instance ID is a primary key so the name is unique per instance and the environment ID is also included for searchability.

Files changed

v1/providers/sfcomputev2/instance.go : added makeSFCName; CreateInstance uses it instead of sanitizeSFCName(attrs.Name)
v1/providers/sfcomputev2/instance_test.go : added tests for determinism (retry safety) and uniqueness across instances

Related Ticket

BREV-12012

@jainvishesh11 jainvishesh11 self-assigned this Sep 18, 2026
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.

1 participant