Skip to content

Commit fd94841

Browse files
committed
fix: make Qdrant/embedding validation optional
Only require qdrant.url, qdrant.api_key, qdrant.collection, and embedding.api_key when VDB routing is explicitly enabled or when pipeline steps that need vector search are configured. This allows configs using only rule-based transfer to load and work correctly.
1 parent 51a14ed commit fd94841

1 file changed

Lines changed: 38 additions & 18 deletions

File tree

internal/core/config/config.go

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -263,25 +263,45 @@ func parseRaw(data []byte) (*Config, error) {
263263
// Note: llm.api_key is intentionally not required here — the process command
264264
// falls back to embedding.api_key when llm.api_key is unset, so rejecting the
265265
// entire config (and losing qdrant.collection) would be worse than proceeding.
266+
//
267+
// Qdrant and embedding fields are only required when VDB features are enabled.
268+
// Configs using only rule-based transfer do not need a vector database.
266269
func (c *Config) Validate() error {
267-
requiredFields := []struct {
268-
name string
269-
envVar string
270-
value string
271-
}{
272-
{name: "qdrant.url", envVar: "QDRANT_URL", value: c.Qdrant.URL},
273-
{name: "qdrant.api_key", envVar: "QDRANT_API_KEY", value: c.Qdrant.APIKey},
274-
{name: "qdrant.collection", envVar: "QDRANT_COLLECTION", value: c.Qdrant.Collection},
275-
{name: "embedding.api_key", envVar: "EMBEDDING_API_KEY", value: c.Embedding.APIKey},
276-
}
277-
278-
for _, field := range requiredFields {
279-
if strings.TrimSpace(field.value) == "" {
280-
return fmt.Errorf(
281-
"config validation failed: %s is empty (check %s environment variable)",
282-
field.name,
283-
field.envVar,
284-
)
270+
// Qdrant and embedding are only required when VDB routing is explicitly enabled
271+
// or when no transfer strategy override is set (backward compat for existing configs
272+
// that always had qdrant configured).
273+
needsVDB := false
274+
if c.Transfer.VDBRouting.Enabled != nil && *c.Transfer.VDBRouting.Enabled {
275+
needsVDB = true
276+
}
277+
// Also require VDB if there are pipeline steps that explicitly need it
278+
for _, step := range c.Steps {
279+
if step == "similarity_search" || step == "indexer" || step == "duplicate_detector" {
280+
needsVDB = true
281+
break
282+
}
283+
}
284+
285+
if needsVDB {
286+
requiredFields := []struct {
287+
name string
288+
envVar string
289+
value string
290+
}{
291+
{name: "qdrant.url", envVar: "QDRANT_URL", value: c.Qdrant.URL},
292+
{name: "qdrant.api_key", envVar: "QDRANT_API_KEY", value: c.Qdrant.APIKey},
293+
{name: "qdrant.collection", envVar: "QDRANT_COLLECTION", value: c.Qdrant.Collection},
294+
{name: "embedding.api_key", envVar: "EMBEDDING_API_KEY", value: c.Embedding.APIKey},
295+
}
296+
297+
for _, field := range requiredFields {
298+
if strings.TrimSpace(field.value) == "" {
299+
return fmt.Errorf(
300+
"config validation failed: %s is empty (check %s environment variable)",
301+
field.name,
302+
field.envVar,
303+
)
304+
}
285305
}
286306
}
287307

0 commit comments

Comments
 (0)