{"record":{"id":"ff07589e0c389a02","repo":"v2rayA/v2rayA","slug":"target-not-specified-ff0758","errorCode":null,"errorMessage":"target not specified","messagePattern":"target not specified","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/hint/proxy/tuic/outbound.go","lineNumber":126,"sourceCode":"\ti := strings.LastIndex(addr, \":\")\n\tif i < 0 {\n\t\treturn addr, \"\", nil\n\t}\n\thost = addr[:i]\n\tport = addr[i+1:]\n\t// Strip brackets from IPv6.\n\tif len(host) >= 2 && host[0] == '[' && host[len(host)-1] == ']' {\n\t\thost = host[1 : len(host)-1]\n\t}\n\treturn host, port, nil\n}\n\n// Process implements proxy.Outbound.\nfunc (c *Client) Process(ctx context.Context, link *transport.Link, _ internet.Dialer) error {\n\toutbounds := xray_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\tdestination := ob.Target\n\n\tdestAddr := fmt.Sprintf(\"%s:%d\", destination.Address.String(), destination.Port.Value())\n\n\tconn, err := c.dialer.DialContext(ctx, \"tcp\", destAddr)\n\tif err != nil {\n\t\treturn errors.New(\"tuic: failed to dial destination\").Base(err)\n\t}\n\tdefer conn.Close()\n\n\tpostRequest := func() error {\n\t\treturn xray_buf.Copy(link.Reader, xray_buf.NewWriter(outboundConnWriter(conn)))\n\t}\n\tgetResponse := func() error {\n\t\treturn xray_buf.Copy(xray_buf.NewReader(outboundConnReader(conn)), link.Writer)\n\t}\n","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/v2rayA/v2rayA/blob/71e5442fc548c05680ee55eae943e6c0afe9ac51/core/hint/proxy/tuic/outbound.go#L108-L144","documentation":"Client.Process implements proxy.Outbound: it takes the last outbound from the xray session context and, if that outbound's Target is not valid (no address/port), aborts with \"target not specified\". The TUIC outbound needs a concrete destination to dial, which is normally supplied by routing.","triggerScenarios":"Calling Process with a context whose outbounds slice's last entry has an invalid Target — e.g. no routing rule matched, the outbound was invoked without a destination, or the session metadata was not attached to the context.","commonSituations":"Routing rules fall through to the TUIC outbound without a target; tests calling Process with a bare context lacking xray_session.OutboundsFromContext entries; misconfigured routing that drops destination info.","solutions":["Fix routing rules so requests reaching this outbound carry a valid destination.","Verify the session with outbounds (including Target) is injected into the context before dispatching to the outbound.","In tests, construct an outbound entry with a valid v2ray destination and put it in the context."],"exampleFix":"// before\nctx := context.Background()\nerr := client.Process(ctx, link, dialer)\n\n// after\noutbounds := xray_session.AppendToContext(context.Background(), &xray_session.Outbound{Target: dest})\nctx = xray_session.ContextWithOutbounds(context.Background(), outbounds)\nerr := client.Process(ctx, link, dialer)","handlingStrategy":"validation","validationCode":"obs := xray_session.OutboundsFromContext(ctx)\nif len(obs) == 0 || !obs[len(obs)-1].Target.IsValid() {\n    return errors.New(\"no valid target in context before Process\")\n}","typeGuard":"func hasValidTarget(ctx context.Context) bool {\n    obs := xray_session.OutboundsFromContext(ctx)\n    return len(obs) > 0 && obs[len(obs)-1].Target.IsValid()\n}","tryCatchPattern":"if err := client.Process(ctx, link, dialer); err != nil {\n    if strings.Contains(err.Error(), \"target not specified\") {\n        // routing produced no destination; check routing rules\n    }\n    return err\n}","preventionTips":["Ensure routing rules always resolve a destination for requests hitting this outbound.","Inject session outbounds into the context in every caller, including tests.","Log the final outbound target before dispatch for debuggability."],"tags":["tuic","routing","missing-target"],"backgroundTag":"missing-target-destination","analyzedSha":"71e5442fc548c05680ee55eae943e6c0afe9ac51","analyzedAt":"2026-09-05T20:04:37.459Z","contentChangedAt":"2026-09-05T20:04:37.459Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}