Billionmail/BillionMail · error
error reading knowledge base
Error message
error reading knowledge base: %v
What it means
ModifyKnowledgeBaseFile first loads the existing knowledge base via ReadKnowledgeBase before applying updates. This error wraps any failure from that read: the file does not exist, cannot be read, or contains invalid JSON. It means the knowledge base identified by (Domain, Kid) could not be loaded, so no modification occurred.
Solutions
- Verify the Kid matches an existing file: list PRODUCT_CONFIG_PATH/<domain>/knowledge/ and confirm <kid>.json exists
- Confirm the same Domain string is used for create, list, and modify calls
- If the file is corrupt, restore valid JSON or delete and recreate the knowledge base via CreateKnowledgeBaseFile
- Check file read permissions on the JSON file
Example fix
// before
ModifyKnowledgeBaseFile(domain, kid, title, content) // kid from stale cache
// after
if err := KnowledgeBaseExists(domain, kid); err != nil {
return CreateKnowledgeBaseFile(domain, title, content, kid) // recreate if missing
}
return ModifyKnowledgeBaseFile(domain, kid, title, content) Defensive patterns
Strategy: validation
Validate before calling
func knowledgeBaseExists(domain, kid string) bool {
return public.FileExists(fmt.Sprintf(PRODUCT_CONFIG_PATH+"/%s/knowledge/%s.json", domain, kid))
}
// before ModifyKnowledgeBaseFile:
if !knowledgeBaseExists(domain, kid) {
return fmt.Errorf("knowledge base %s not found for %s", kid, domain)
} Try / catch
if err := ModifyKnowledgeBaseFile(domain, kid, title, content); err != nil {
if strings.Contains(err.Error(), "reading knowledge base") {
// treat as not-found: surface 404 to caller or recreate
}
} Prevention
- Fetch the current list (GetKnowledgeBaseList) before editing so Kid values are fresh
- Keep a single source of truth for Domain strings (no case/whitespace drift)
- Validate Kid format (UUID) client-side before calls
- Avoid externally editing knowledge JSON files with non-conforming tools
When it happens
Trigger: ReadKnowledgeBase(Domain, Kid) returns an error because: no file exists at PRODUCT_CONFIG_PATH/<domain>/knowledge/<kid>.json (wrong Kid, wrong domain, or entry was deleted); the file is unreadable due to permissions; the JSON content is corrupt and fails to unmarshal (the inner 'error unmarshalling knowledge base').
Common situations: Client passes a stale Kid after the knowledge base was deleted; Kid casing or truncation mismatch (e.g. Kid derived from a filename split on '.'); domain mismatch between create and modify calls; file edited externally with invalid JSON.
Understand the failure class
Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.
Related errors
- error marshalling knowledge base
- alert settings file is empty
- error creating company profile file
- error creating project configuration
- error getting prompt config
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/d55b41b6ea7b4175.
Report an issue: GitHub.
Appendix: source
Thrown at core/internal/service/askai/project.go:384
Tid = GetUUID()
}
knowledge := KnowledgeInfo{
Kid: Tid,
Title: Title,
Content: Content,
UpdateTime: public.GetNowTime(),
}
return SaveKnowledgeBase(Domain, knowledge)
}
// ModifyKnowledgeBaseFile updates the title and content of an existing knowledge base file.
// It reads the existing knowledge base, modifies the specified fields, and saves the updated knowledge base.
// If the knowledge base does not exist or cannot be read, it returns an error.
func ModifyKnowledgeBaseFile(Domain string, Kid string, Title string, Content string) error {
knowledge, err := ReadKnowledgeBase(Domain, Kid)
if err != nil {
return fmt.Errorf("error reading knowledge base: %v", err)
}
// Update the knowledge base information
if Title != "" {
knowledge.Title = Title
}
if Content != "" {
knowledge.Content = Content
}
knowledge.UpdateTime = public.GetNowTime()
err = SaveKnowledgeBase(Domain, knowledge)
if err != nil {
return fmt.Errorf("error saving knowledge base: %v", err)
}
return nil
}
View on GitHub (pinned to fc36c76c05)