Billionmail/BillionMail · error
error getting site map: %v
Error message
error getting site map: %v
What it means
AddSiteMapNode reads the current sitemap via GetSiteMap and wraps any GetSiteMap failure with 'error getting site map: %v'. The root cause is always one of the underlying GetSiteMap errors: bootstrap write failure (missing/unwritable dir), read failure (deleted file/permissions), or unmarshal failure (corrupt JSON). The error therefore appears doubly wrapped and must be unwound to diagnose.
Source
Thrown at core/internal/service/askai/project.go:650
filename := fmt.Sprintf(PRODUCT_CONFIG_PATH+"/%s/sitemap.json", Domain)
data, err := json.MarshalIndent(siteMap, "", " ")
if err != nil {
return fmt.Errorf("error marshalling site map: %v", err)
}
err = os.WriteFile(filename, data, 0644)
if err != nil {
return fmt.Errorf("error saving site map file: %v", err)
}
return nil
}
// AddSiteMapNode adds a new site map node with the provided title and URI path to the site map of the specified domain.
// It reads the existing site map, appends the new node, and saves the updated site map back to the file.
// If the site map file does not exist or cannot be read, it returns an error.
func AddSiteMapNode(Domain string, Title string, UriPath string) error {
siteMap, err := GetSiteMap(Domain)
if err != nil {
return fmt.Errorf("error getting site map: %v", err)
}
newNode := SiteMap{
Title: Title,
UriPath: UriPath,
UpdateTime: public.GetNowTime(),
}
siteMap = append(siteMap, newNode)
filename := fmt.Sprintf(PRODUCT_CONFIG_PATH+"/%s/sitemap.json", Domain)
data, err := json.MarshalIndent(siteMap, "", " ")
if err != nil {
return fmt.Errorf("error marshalling site map: %v", err)
}
err = os.WriteFile(filename, data, 0644)
if err != nil {
return fmt.Errorf("error saving site map file: %v", err)
}View on GitHub (pinned to fc36c76c05)
Solutions
- Unwrap the chain (%v inside %v) and match the inner cause: create the domain dir (MkdirAll), fix file permissions, or repair/delete corrupt sitemap.json.
- Fix the corresponding GetSiteMap root cause first — this wrapper adds no handling of its own.
- Validate sitemap.json with jq before re-attempting the node add if corruption is suspected.
- Add a guard in AddSitemapNode's caller to provision the domain config directory during domain creation, so first-write never fails.
Example fix
// before
siteMap, err := GetSiteMap(Domain)
if err != nil {
return fmt.Errorf("error getting site map: %v", err)
}
// after
if err := os.MkdirAll(filepath.Join(PRODUCT_CONFIG_PATH, Domain), 0755); err != nil {
return fmt.Errorf("error ensuring config dir: %v", err)
}
siteMap, err := GetSiteMap(Domain)
if err != nil {
return fmt.Errorf("error getting site map: %w", err) // %w preserves the wrapped cause for errors.Is/As
} Defensive patterns
Strategy: try-catch
Validate before calling
func canAddSitemapNode(domain string) error {
dir := filepath.Join(PRODUCT_CONFIG_PATH, domain)
if err := os.MkdirAll(dir, 0755); err != nil { return err }
p := filepath.Join(dir, "sitemap.json")
if data, err := os.ReadFile(p); err == nil {
var m []SiteMap
if err := json.Unmarshal(data, &m); err != nil {
return fmt.Errorf("corrupt sitemap: %w", err)
}
}
return nil // missing file is fine: GetSiteMap bootstraps it
} Try / catch
if err := AddSiteMapNode(domain, title, uri); err != nil {
log.Printf("add node failed: %v", err) // full wrapped chain
switch {
case strings.Contains(err.Error(), "error saving empty site map file"):
os.MkdirAll(filepath.Join(PRODUCT_CONFIG_PATH, domain), 0755)
case strings.Contains(err.Error(), "error unmarshalling site map"):
// quarantine corrupt file, then retry
os.Rename(filepath.Join(PRODUCT_CONFIG_PATH, domain, "sitemap.json"), ".../sitemap.json.bad")
}
return err
} Prevention
- Provision the domain config directory at domain creation so first read/bootstrap always succeeds.
- Use %w instead of %v at wrap sites so errors.Is/As can match root causes across the chain.
- Validate sitemap.json integrity before bulk node additions.
- Keep GetSiteMap healthy — this error is purely a proxy for its failures.
When it happens
Trigger: Calling AddSiteMapNode (or AddSitemapNode) for a domain where sitemap.json cannot be read or created: missing PRODUCT_CONFIG_PATH/<domain>/ directory, unreadable sitemap.json, or corrupt/invalid JSON content.
Common situations: First node added to a brand-new domain whose directory does not exist (triggers the bootstrap write failure path); corrupt sitemap.json from a prior crash or manual edit; permission changes after a user switch.
Related errors
- error getting footer config: %v
- error reading project configuration: %v
- error getting knowledge base list: %v
- error saving project configuration: %v
- knowledge base file does not exist: %s
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/f2a0131ace4a8c88.
Report an issue: GitHub.