{"record":{"id":"c0f57a5a1e54bf7f","repo":"vxcontrol/pentagi","slug":"barrier-function-s-not-found","errorCode":null,"errorMessage":"barrier function %s not found","messagePattern":"barrier function (.+?) not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/tools.go","lineNumber":794,"sourceCode":"\tfor _, def := range cfg.Definitions {\n\t\tif _, ok := cfg.Handlers[def.Name]; !ok {\n\t\t\treturn nil, fmt.Errorf(\"handler for function %s not found\", def.Name)\n\t\t}\n\t}\n\n\tfor _, builtin := range cfg.Builtin {\n\t\tif def, ok := fte.definitions[builtin]; !ok {\n\t\t\treturn nil, fmt.Errorf(\"builtin function %s not found\", builtin)\n\t\t} else {\n\t\t\tcfg.Definitions = append(cfg.Definitions, def)\n\t\t\tcfg.Handlers[builtin] = fte.handlers[builtin]\n\t\t}\n\t}\n\n\tbarriers := make(map[string]struct{})\n\tfor _, barrier := range cfg.Barriers {\n\t\tif _, ok := fte.handlers[barrier]; !ok {\n\t\t\treturn nil, fmt.Errorf(\"barrier function %s not found\", barrier)\n\t\t}\n\t\tbarriers[barrier] = struct{}{}\n\t}\n\n\treturn &customExecutor{\n\t\tuserID:      fte.userID,\n\t\tflowID:      fte.flowID,\n\t\ttaskID:      cfg.TaskID,\n\t\tsubtaskID:   cfg.SubtaskID,\n\t\tmlp:         fte.mlp,\n\t\ttclp:        fte.tclp,\n\t\tvslp:        fte.vslp,\n\t\tdb:          fte.db,\n\t\tstore:       fte.store,\n\t\tdefinitions: cfg.Definitions,\n\t\thandlers:    cfg.Handlers,\n\t\tbarriers:    barriers,\n\t\tsummarizer:  cfg.Summarizer,","sourceCodeStart":776,"sourceCodeEnd":812,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/tools.go#L776-L812","documentation":"flowToolsExecutor validates that every barrier function name listed in cfg.Barriers exists in its registered tool handlers map (fte.handlers). Barriers are special flow-control functions (e.g. task done markers) that must be backed by a registered handler. If a configured barrier name has no matching handler, executor construction is aborted with this error.","triggerScenarios":"Calling GetCustomExecutor (or a similar constructor path that loops over cfg.Barriers) with a Barriers slice containing a name that was never registered in the tool executor's handlers map — typically a typo, a renamed tool, or a barrier name only registered by a different executor type (e.g. GetPrimaryExecutor registers \"done\" but GetCustomExecutor does not).","commonSituations":"Copy-pasting executor config between flow types; upgrading PentAGI where a barrier/tool was renamed; hand-writing config with a misspelled barrier string; passing barrier names valid for the primary executor into a custom executor.","solutions":["Check the barrier names in cfg.Barriers against the keys registered in fte.handlers for the executor type you are constructing and fix typos/renames.","Remove the barrier entry if this executor type does not support it (barriers like \"done\" belong to the primary executor).","Register the missing barrier function in the handlers map before calling GetCustomExecutor.","If a recent upgrade caused it, compare old and new barrier/tool names in the providers/executor setup code."],"exampleFix":"// before\nexecutor, err := fte.GetCustomExecutor(CustomExecutorConfig{\n  Handlers: map[string]FunctionHandler{\"task_done\": h},\n  Barriers: []string{\"done\"}, // wrong: not in handlers\n})\n// after\nexecutor, err := fte.GetCustomExecutor(CustomExecutorConfig{\n  Handlers: map[string]FunctionHandler{\"task_done\": h},\n  Barriers: []string{\"task_done\"}, // must match a registered handler\n})","handlingStrategy":"validation","validationCode":"registered := map[string]struct{}{\"task_done\": {}, \"done\": {}} // mirror of handlers known to be registered\nfor _, b := range cfg.Barriers {\n    if _, ok := registered[b]; !ok {\n        return fmt.Errorf(\"unknown barrier %q\", b)\n    }\n}","typeGuard":null,"tryCatchPattern":"executor, err := fte.GetCustomExecutor(cfg)\nif err != nil {\n    if strings.Contains(err.Error(), \"barrier function\") {\n        // log cfg.Barriers and the registered handler keys, fail fast\n    }\n    return err\n}","preventionTips":["Keep barrier names as named constants shared with handler registration keys.","Never hardcode barrier strings in config; derive them from the handlers map you build.","After tool renames, grep for the old barrier name across config and setup code."],"tags":["configuration","tools-executor","barrier"],"backgroundTag":"unregistered-barrier-function","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}