{"record":{"id":"534797cbcf103806","repo":"snail007/goproxy","slug":"unkown-parent-type-s","errorCode":null,"errorMessage":"unkown parent type %s","messagePattern":"unkown parent type (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"services/tcp.go","lineNumber":77,"sourceCode":"func (s *TCP) Clean() {\n\ts.StopService()\n}\nfunc (s *TCP) callback(inConn net.Conn) {\n\tdefer func() {\n\t\tif err := recover(); err != nil {\n\t\t\tlog.Printf(\"%s conn handler crashed with err : %s \\nstack: %s\", s.cfg.Protocol(), err, string(debug.Stack()))\n\t\t}\n\t}()\n\tvar err error\n\tswitch *s.cfg.ParentType {\n\tcase TYPE_TCP:\n\t\tfallthrough\n\tcase TYPE_TLS:\n\t\terr = s.OutToTCP(&inConn)\n\tcase TYPE_UDP:\n\t\terr = s.OutToUDP(&inConn)\n\tdefault:\n\t\terr = fmt.Errorf(\"unkown parent type %s\", *s.cfg.ParentType)\n\t}\n\tif err != nil {\n\t\tlog.Printf(\"connect to %s parent %s fail, ERR:%s\", *s.cfg.ParentType, *s.cfg.Parent, err)\n\t\tutils.CloseConn(&inConn)\n\t}\n}\nfunc (s *TCP) OutToTCP(inConn *net.Conn) (err error) {\n\tvar outConn net.Conn\n\tvar _outConn interface{}\n\t_outConn, err = s.outPool.Pool.Get()\n\tif err == nil {\n\t\toutConn = _outConn.(net.Conn)\n\t}\n\tif err != nil {\n\t\tlog.Printf(\"connect to %s , err:%s\", *s.cfg.Parent, err)\n\t\tutils.CloseConn(inConn)\n\t\treturn\n\t}","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/snail007/goproxy/blob/e6d6a821db80e7f47ee6e981a144984e1d4ddb3d/services/tcp.go#L59-L95","documentation":"The TCP service callback connects to a parent based on cfg.ParentType (tcp/tls/udp). This error is the switch's default branch: the configured ParentType value does not match any supported type, so the connection is dropped, logged, and the incoming connection closed.","triggerScenarios":"*s.cfg.ParentType holds a value other than the handled TYPE_TCP/TYPE_TLS/TYPE_UDP constants — e.g. an empty string, wrong case, or an unsupported mode like 'kcp' in a build that does not handle it — causing callback to hit default and fail.","commonSituations":"Missing/blank parent_type in the config file; typo such as 'TCP' vs 'tcp' depending on parsing; config copied from a version supporting a parent type this build does not compile in.","solutions":["Set parent_type in the config to a supported value (tcp, tls, or udp as handled in services/tcp.go)","Check for whitespace/case issues in the config value and trim/normalize it","Verify the binary build supports the configured parent type and upgrade if needed","If parent should be optional, confirm the default value is applied when the field is empty"],"exampleFix":"// before\n// parent_type=tcps   (unrecognized)\n// after\n// parent_type=tls","handlingStrategy":"validation","validationCode":"switch strings.ToLower(strings.TrimSpace(cfg.ParentType)) {\ncase \"tcp\", \"tls\", \"udp\":\n    // ok\ndefault:\n    return fmt.Errorf(\"parent_type %q must be tcp|tls|udp\", cfg.ParentType)\n}","typeGuard":null,"tryCatchPattern":"if err := svc.Start(); err != nil {\n    if strings.Contains(err.Error(), \"unkown parent type\") {\n        log.Fatalf(\"fix parent_type in config: got %q, want tcp|tls|udp\", cfg.ParentType)\n    }\n}","preventionTips":["Always set parent_type explicitly; never leave it blank","Use lowercase values exactly as documented","Lint config files at deploy time for allowed enum values","When copying configs between environments, re-validate enum fields"],"tags":["configuration","tcp","parent-type"],"backgroundTag":"unknown-parent-type","analyzedSha":"e6d6a821db80e7f47ee6e981a144984e1d4ddb3d","analyzedAt":"2026-09-03T15:32:42.750Z","contentChangedAt":"2026-09-03T15:32:42.750Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}