admin: pass an index without non-filterable keys as an empty list

An index whose record holds a metadata configuration with no key list
was rendered as `null`, and the dialog's non-filterable check then threw
before it could submit or show an error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-11-20 00:39:01 -08:00
1 parent 9012c7f0c7
commit 77f9b35885
3 files changed
+23 -3

No files matched your search

@@ -386,7 +386,7 @@ func groupDigits(n float64) string {
func nonFilterableJSON(index *s3vectors.Index) string {
keys := []string{}
if index.MetadataConfiguration != nil {
if index.MetadataConfiguration != nil && index.MetadataConfiguration.NonFilterableMetadataKeys != nil {
keys = index.MetadataConfiguration.NonFilterableMetadataKeys
}
b, _ := json.Marshal(keys)
@@ -853,7 +853,7 @@ func groupDigits(n float64) string {
func nonFilterableJSON(index *s3vectors.Index) string {
keys := []string{}
if index.MetadataConfiguration != nil {
if index.MetadataConfiguration != nil && index.MetadataConfiguration.NonFilterableMetadataKeys != nil {
keys = index.MetadataConfiguration.NonFilterableMetadataKeys
}
b, _ := json.Marshal(keys)
@@ -1,6 +1,10 @@
package app
import "testing"
import (
"testing"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3vectors"
)
func TestGroupDigits(t *testing.T) {
for n, want := range map[float64]string{0: "0", 999: "999", 1000: "1,000", 12400: "12,400", 2140312: "2,140,312", 8899.6: "8,900"} {
@@ -9,3 +13,19 @@ func TestGroupDigits(t *testing.T) {
}
}
}
func TestNonFilterableJSONIsAlwaysAList(t *testing.T) {
for _, index := range []*s3vectors.Index{
{},
{MetadataConfiguration: &s3vectors.MetadataConfiguration{}},
{MetadataConfiguration: &s3vectors.MetadataConfiguration{NonFilterableMetadataKeys: []string{}}},
} {
if got := nonFilterableJSON(index); got != "[]" {
t.Errorf("%+v: %s", index.MetadataConfiguration, got)
}
}
index := &s3vectors.Index{MetadataConfiguration: &s3vectors.MetadataConfiguration{NonFilterableMetadataKeys: []string{"body"}}}
if got := nonFilterableJSON(index); got != `["body"]` {
t.Error(got)
}
}