Skip to content

Commit 5c1944d

Browse files
committed
Stop applying name prefix to vector_search_indexes
The 3-part UC name (catalog.schema.index) is the API primary key: CreateIndex addresses by name and DoCreate returns it as the deployment id. Prefixing it changed which remote object the bundle addressed, not just its display label. Mirrors #5209's same change for vector_search_endpoints. Drop the leaf-only prefix loop and the vectorSearchIndexPrefixPos helper in apply_presets.go, add VectorSearchIndex to the no-rename carve-out in apply_target_mode_test.go, and remove the now-obsolete TestVectorSearchIndexNamePrefixing. Co-authored-by: Isaac
1 parent 4c68ad5 commit 5c1944d

4 files changed

Lines changed: 12 additions & 87 deletions

File tree

acceptance/bundle/validate/presets_name_prefix/output.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"vs_index": {
4141
"endpoint_name": "vs_endpoint",
4242
"index_type": "DELTA_SYNC",
43-
"name": "my_catalog.my_schema.prefixmy_index",
43+
"name": "my_catalog.my_schema.my_index",
4444
"primary_key": "id"
4545
}
4646
},
@@ -95,7 +95,7 @@
9595
"vs_index": {
9696
"endpoint_name": "vs_endpoint",
9797
"index_type": "DELTA_SYNC",
98-
"name": "my_catalog.my_schema.prefix_my_index",
98+
"name": "my_catalog.my_schema.my_index",
9999
"primary_key": "id"
100100
}
101101
},

acceptance/bundle/validate/presets_name_prefix_vs_index_endpoint/output.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
"vs_index_literal": {
1212
"endpoint_name": "vs_endpoint",
1313
"index_type": "DELTA_SYNC",
14-
"name": "my_catalog.my_schema.prefix_literal_index",
14+
"name": "my_catalog.my_schema.literal_index",
1515
"primary_key": "id"
1616
},
1717
"vs_index_partial_ref": {
1818
"endpoint_name": "${resources.vector_search_endpoints.vs_endpoint.name}",
1919
"index_type": "DELTA_SYNC",
20-
"name": "my_catalog.my_schema.prefix_partial_ref_index",
20+
"name": "my_catalog.my_schema.partial_ref_index",
2121
"primary_key": "id"
2222
},
2323
"vs_index_ref": {
2424
"endpoint_name": "${resources.vector_search_endpoints.vs_endpoint.name}",
2525
"index_type": "DELTA_SYNC",
26-
"name": "my_catalog.my_schema.prefix_ref_index",
26+
"name": "my_catalog.my_schema.ref_index",
2727
"primary_key": "id"
2828
}
2929
}

bundle/config/mutator/resourcemutator/apply_presets.go

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -294,17 +294,10 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
294294
// (it's what GET/UPDATE/DELETE address by), so prefixing it would change
295295
// the resource's identity rather than just its display name.
296296

297-
// Vector Search Indexes: Prefix
298-
// The name is a 3-part UC identifier (catalog.schema.index); prefix only
299-
// the last component since catalog and schema are external references.
300-
for _, e := range r.VectorSearchIndexes {
301-
if e == nil {
302-
continue
303-
}
304-
if pos := vectorSearchIndexPrefixPos(e.Name); pos >= 0 {
305-
e.Name = e.Name[:pos] + normalizePrefix(prefix) + e.Name[pos:]
306-
}
307-
}
297+
// Vector Search Indexes: no prefix. The 3-part UC name (catalog.schema.index)
298+
// is the API primary key (CreateIndex addresses by name and DoCreate returns
299+
// it as the deployment id), so prefixing would change the resource's
300+
// identity rather than just its display name.
308301

309302
return diags
310303
}
@@ -337,28 +330,6 @@ func toTagArray(tags map[string]string) []Tag {
337330
return tagArray
338331
}
339332

340-
// vectorSearchIndexPrefixPos returns the byte offset at which to insert the
341-
// name prefix into a vector search index name, or -1 to skip prefixing.
342-
//
343-
// ApplyPresets runs before reference/variable resolution, so the name may
344-
// still carry literal `${...}` tokens. We walk back from the end and prefix
345-
// at the first `.` we find, which is the catalog.schema.index separator
346-
// once the literal tail is non-empty. If we instead hit `$` or `}` first,
347-
// the tail is occluded by a `${...}` expression and prefixing would corrupt
348-
// it (e.g. `${var.full_name}` -> `${var.dev_user_full_name}`); in that case
349-
// skip and let the user compose the prefix into the variable.
350-
func vectorSearchIndexPrefixPos(name string) int {
351-
for i := len(name) - 1; i >= 0; i-- {
352-
switch name[i] {
353-
case '.':
354-
return i + 1
355-
case '$', '}':
356-
return -1
357-
}
358-
}
359-
return 0
360-
}
361-
362333
// normalizePrefix prefixes strings like '[dev lennart] ' to 'dev_lennart_'.
363334
// We leave unicode letters and numbers but remove all "special characters."
364335
func normalizePrefix(prefix string) string {

bundle/config/mutator/resourcemutator/apply_target_mode_test.go

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ func TestProcessTargetModeDevelopment(t *testing.T) {
316316
// Vector search endpoint 1: name is the primary key, so it must not be prefixed.
317317
assert.Equal(t, "vs_endpoint1", b.Config.Resources.VectorSearchEndpoints["vs_endpoint1"].Name)
318318

319-
// Vector search index 1: only the leaf name is prefixed, since catalog and schema are external
320-
assert.Equal(t, "main.default.dev_lennart_vs_index1", b.Config.Resources.VectorSearchIndexes["vs_index1"].Name)
319+
// Vector search index 1: name is the primary key, so it must not be prefixed.
320+
assert.Equal(t, "main.default.vs_index1", b.Config.Resources.VectorSearchIndexes["vs_index1"].Name)
321321

322322
// Registered model 1
323323
assert.Equal(t, "dev_lennart_registeredmodel1", b.Config.Resources.RegisteredModels["registeredmodel1"].Name)
@@ -440,6 +440,7 @@ func TestAppropriateResourcesAreRenamed(t *testing.T) {
440440
reflect.TypeFor[*resources.ExternalLocation](),
441441
reflect.TypeFor[*resources.Volume](),
442442
reflect.TypeFor[*resources.VectorSearchEndpoint](),
443+
reflect.TypeFor[*resources.VectorSearchIndex](),
443444
}
444445

445446
// Resources whose Name is server-generated or otherwise not a user-facing
@@ -506,53 +507,6 @@ func TestDisableLockingDisabled(t *testing.T) {
506507
assert.True(t, b.Config.Bundle.Deployment.Lock.IsEnabled(), "Deployment lock should remain enabled in development mode when explicitly enabled")
507508
}
508509

509-
func TestVectorSearchIndexNamePrefixing(t *testing.T) {
510-
cases := []struct {
511-
key string
512-
name string
513-
want string
514-
}{
515-
{
516-
// Trailing component is a ref: skip, since prefixing would inject
517-
// the prefix inside the ${var.index} expression.
518-
key: "vs_index_all_refs",
519-
name: "${var.catalog}.${var.schema}.${var.index}",
520-
want: "${var.catalog}.${var.schema}.${var.index}",
521-
},
522-
{
523-
// Catalog and schema are refs but the leaf is literal: prefix the leaf.
524-
key: "vs_index_partial_ref",
525-
name: "${var.catalog}.${var.schema}.non_ref_name",
526-
want: "${var.catalog}.${var.schema}.dev_lennart_non_ref_name",
527-
},
528-
{
529-
// Whole name is a single ref: skip.
530-
key: "vs_index_full_ref",
531-
name: "${var.full_name}",
532-
want: "${var.full_name}",
533-
},
534-
}
535-
536-
b := mockBundle(config.Development)
537-
for _, c := range cases {
538-
b.Config.Resources.VectorSearchIndexes[c.key] = &resources.VectorSearchIndex{
539-
CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{
540-
Name: c.name,
541-
EndpointName: "vs_endpoint1",
542-
PrimaryKey: "id",
543-
IndexType: vectorsearch.VectorIndexTypeDeltaSync,
544-
},
545-
}
546-
}
547-
548-
diags := bundle.ApplySeq(t.Context(), b, ApplyTargetMode(), ApplyPresets())
549-
require.NoError(t, diags.Error())
550-
551-
for _, c := range cases {
552-
assert.Equal(t, c.want, b.Config.Resources.VectorSearchIndexes[c.key].Name, c.key)
553-
}
554-
}
555-
556510
func TestPrefixAlreadySet(t *testing.T) {
557511
b := mockBundle(config.Development)
558512
b.Config.Presets.NamePrefix = "custom_lennart_deploy_"

0 commit comments

Comments
 (0)