fix
This commit is contained in:
@@ -7,13 +7,21 @@ import (
|
||||
)
|
||||
|
||||
// categoryDisplayLabel returns the human category name for meta / synthesize /
|
||||
// {{category}}. Prefers CategoryName; never falls back to a digits-only unique_id.
|
||||
// {{category}}. Prefers taxonomy CategoryName; never falls back to a digits-only
|
||||
// unique_id, prompt/formula leakage, or the product title itself.
|
||||
func categoryDisplayLabel(result StepResult) string {
|
||||
if n := strings.TrimSpace(result.CategoryName); n != "" {
|
||||
return n
|
||||
// CategoryName comes from categories.name — trust unless prompt leakage.
|
||||
if !isPromptLabelTitle(n) {
|
||||
return n
|
||||
}
|
||||
}
|
||||
cat := strings.TrimSpace(result.Category)
|
||||
if cat == "" || isDigitsOnlyCategoryID(cat) {
|
||||
if cat == "" || isDigitsOnlyCategoryID(cat) || isPromptLabelTitle(cat) {
|
||||
return ""
|
||||
}
|
||||
// Unresolved non-uid token: never surface the product name as {{category}}.
|
||||
if categoryTokenEqualsProductTitle(cat, result.ProcessedName, result.Name) {
|
||||
return ""
|
||||
}
|
||||
return cat
|
||||
@@ -109,6 +117,10 @@ func normalizeCategoryUniqueID(s string) string {
|
||||
if s == "" || s == "<nil>" || strings.EqualFold(s, "none") {
|
||||
return ""
|
||||
}
|
||||
// Never treat enhance-prompt / formula scaffolding as a category unique_id.
|
||||
if isPromptLabelTitle(s) {
|
||||
return ""
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
@@ -155,7 +167,10 @@ func applyCategoryFromMapped(out *StepResult, maps ...map[string]any) {
|
||||
return
|
||||
}
|
||||
cat := categoryUniqueIDFromMaps(maps...)
|
||||
if cat == "" {
|
||||
// Prompt/formula leakage never becomes Category. Product-title equals are
|
||||
// scrubbed later (scrubCategoryPollution) so a title that matches a real
|
||||
// taxonomy display name can still coerce to unique_id.
|
||||
if cat == "" || isPromptLabelTitle(cat) {
|
||||
return
|
||||
}
|
||||
out.Category = SanitizeText(cat)
|
||||
@@ -213,6 +228,15 @@ func coerceCategoryToCompanyUniqueID(out *StepResult, namesByUID map[string]stri
|
||||
if cat == "" {
|
||||
return
|
||||
}
|
||||
if isPromptLabelTitle(cat) {
|
||||
out.Category = ""
|
||||
out.CategoryName = ""
|
||||
if out.FieldSources == nil {
|
||||
out.FieldSources = map[string]any{}
|
||||
}
|
||||
out.FieldSources["category"] = "cleared_invalid"
|
||||
return
|
||||
}
|
||||
resolved := resolveCompanyCategoryUniqueID(cat, namesByUID, valid)
|
||||
if resolved == "" || resolved == cat {
|
||||
return
|
||||
@@ -241,8 +265,10 @@ func filterCategoryIfInvalid(out *StepResult, valid map[string]struct{}) {
|
||||
return
|
||||
}
|
||||
out.Category = ""
|
||||
if out.FieldSources != nil {
|
||||
delete(out.FieldSources, "category")
|
||||
out.CategoryName = ""
|
||||
if out.FieldSources == nil {
|
||||
out.FieldSources = map[string]any{}
|
||||
}
|
||||
out.FieldSources["category"] = "cleared_invalid"
|
||||
out.Notes = append(out.Notes, "category: ignored (unknown unique_id for company)")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user