{"record":{"id":"4247194c48693209","repo":"XTLS/Xray-core","slug":"target-not-specified-424719","errorCode":null,"errorMessage":"target not specified.","messagePattern":"target not specified\\.","errorType":"exception","errorClass":"errors.Error","httpStatus":null,"severity":"error","filePath":"proxy/http/client.go","lineNumber":73,"sourceCode":"\tserver, err := protocol.NewServerSpecFromPB(config.Server)\n\tif err != nil {\n\t\treturn nil, errors.New(\"failed to get server spec\").Base(err)\n\t}\n\n\tv := core.MustFromContext(ctx)\n\treturn &Client{\n\t\tserver:        server,\n\t\tpolicyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),\n\t\theader:        config.Header,\n\t}, nil\n}\n\n// Process implements proxy.Outbound.Process. We first create a socket tunnel via HTTP CONNECT method, then redirect all inbound traffic to that tunnel.\nfunc (c *Client) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error {\n\toutbounds := session.OutboundsFromContext(ctx)\n\tob := outbounds[len(outbounds)-1]\n\tif !ob.Target.IsValid() {\n\t\treturn errors.New(\"target not specified.\")\n\t}\n\tob.Name = \"http\"\n\tob.CanSpliceCopy = 2\n\ttarget := ob.Target\n\ttargetAddr := target.NetAddr()\n\n\tif target.Network == net.Network_UDP {\n\t\treturn errors.New(\"UDP is not supported by HTTP outbound\")\n\t}\n\n\tserver := c.server\n\tdest := server.Destination\n\tuser := server.User\n\tvar conn stat.Connection\n\n\tmbuf, _ := link.Reader.ReadMultiBuffer()\n\tlen := mbuf.Len()\n\tfirstPayload := bytespool.Alloc(len)","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/http/client.go#L55-L91","documentation":"HTTP outbound's Process found the session's last outbound has an invalid Target. Like freedom, the HTTP CONNECT client needs a concrete destination to request from the proxy; without it the request line cannot be built and the handler bails immediately.","triggerScenarios":"Dispatcher routes a session to the HTTP outbound where ob.Target was never populated (inbound failed to parse destination, or a chained handler did not propagate it).","commonSituations":"Routing rules sending target-less traffic (internal, metadata-less) to the HTTP outbound; transparent inbound without original-dst recovery; custom outbounds not calling SetTarget.","solutions":["Ensure the inbound produces a valid destination before routing to the http outbound","Fix routing so only fully-qualified traffic (with host:port) reaches this outbound","Programmatic users: set outbound.Target before dispatch"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"```go\nobs := session.OutboundsFromContext(ctx)\nif len(obs) == 0 || !obs[len(obs)-1].Target.IsValid() {\n    // refuse before dispatching to the http outbound\n}\n```","typeGuard":"```go\nfunc lastTargetValid(ctx context.Context) bool {\n    obs := session.OutboundsFromContext(ctx)\n    return len(obs) > 0 && obs[len(obs)-1].Target.IsValid()\n}\n```","tryCatchPattern":null,"preventionTips":["Set Target on every outbound you construct","Route only fully-addressed sessions to http outbound"],"tags":["http-outbound","target","session","xray"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}