{"record":{"id":"67060c0e849f525f","repo":"Billionmail/BillionMail","slug":"error-getting-knowledge-base-list-v","errorCode":null,"errorMessage":"error getting knowledge base list: %v","messagePattern":"error getting knowledge base list: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/askai/project.go","lineNumber":208,"sourceCode":"\t// Return only the base information\n\tbaseInfo := ProjectConfig{\n\t\tDomain:        config.Domain,\n\t\tUrls:          config.Urls,\n\t\tProjectName:   config.ProjectName,\n\t\tDescription:   config.Description,\n\t\tIndustry:      config.Industry,\n\t\tPrimaryLogo:   config.PrimaryLogo,\n\t\tSecondaryLogo: config.SecondaryLogo,\n\t\tFavicon:       config.Favicon,\n\t\tUpdateTime:    config.UpdateTime,\n\t\tStatus:        config.Status,\n\t}\n\n\t// Get the knowledge base list\n\t// This will populate the KnowledgeBase field in the baseInfo struct.\n\tbaseInfo.KnowledgeBase, err = GetKnowledgeBaseList(Domain)\n\tif err != nil {\n\t\treturn ProjectConfig{}, fmt.Errorf(\"error getting knowledge base list: %v\", err)\n\t}\n\n\treturn baseInfo, nil\n}\n\n// GetProjectStatus retrieves the status of a project configuration based on the provided domain.\n// It reads the project configuration and returns a boolean indicating whether the project is active or not.\nfunc GetProjectStatus(Domain string) (bool, bool, error) {\n\tconfig, err := ReadProjectConfig(Domain)\n\tif err != nil {\n\t\treturn false, false, nil\n\t}\n\n\t// Return the project status\n\treturn config.Status, true, nil\n}\n\n// SetProjectStatus updates the status of a project configuration based on the provided domain.","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/askai/project.go#L190-L226","documentation":"After successfully loading the project config, GetBaseInfo calls GetKnowledgeBaseList(Domain) to populate the KnowledgeBase field. If that call fails (directory listing error, unreadable knowledge JSON files), the error is wrapped as 'error getting knowledge base list: %v'. The whole GetBaseInfo call returns empty, so a knowledge-base storage problem blocks base-info retrieval even though the config itself was fine.","triggerScenarios":"GetBaseInfo(Domain) where GetKnowledgeBaseList fails: the domain's knowledge/ directory cannot be read, or one of the knowledge JSON files is unreadable/unparsable during listing.","commonSituations":"knowledge/ subdirectory deleted or never created with wrong permissions; a knowledge file truncated by a failed SaveKnowledgeBase; disk full preventing directory reads; domain path mismatch so listing targets a nonexistent directory.","solutions":["Check the domain's PRODUCT_CONFIG_PATH/<domain>/knowledge/ directory exists and is readable","Validate each knowledge *.json file parses; remove or repair corrupt files","Call GetKnowledgeBaseList directly with the same domain to see the unwrapped error","Check disk space and directory permissions for the process user","Recreate missing knowledge entries or tolerate an empty list in the caller"],"exampleFix":"// before\nbase, err := askai.GetBaseInfo(domain)\n// after\nbase, err := askai.GetBaseInfo(domain)\nif err != nil {\n    var listErr error\n    _, listErr = askai.GetKnowledgeBaseList(domain)\n    log.Printf(\"base info failed; kb listing: %v\", listErr)\n    return err\n}","handlingStrategy":"try-catch","validationCode":"kbDir := fmt.Sprintf(PRODUCT_CONFIG_PATH+\"/%s/knowledge\", domain)\nif fi, err := os.Stat(kbDir); err != nil || !fi.IsDir() {\n    os.MkdirAll(kbDir, 0o755)\n}","typeGuard":"func knowledgeDirReadable(domain string) bool {\n    f, err := os.Open(fmt.Sprintf(PRODUCT_CONFIG_PATH+\"/%s/knowledge\", domain))\n    if err != nil { return false }\n    f.Close()\n    return true\n}","tryCatchPattern":"base, err := askai.GetBaseInfo(domain)\nif err != nil && strings.Contains(err.Error(), \"knowledge base list\") {\n    base.KnowledgeBase = nil // degrade gracefully\n} else if err != nil {\n    return err\n}","preventionTips":["Create the knowledge/ directory when initializing a project","Validate every knowledge JSON after saving","Monitor disk space on the config volume","Call GetKnowledgeBaseList independently to isolate failures","Treat an empty/failed KB list as non-fatal where possible"],"tags":["go","file-io","knowledge-base"],"backgroundTag":"knowledge-base-list-failed","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}