{"record":{"id":"d0461eab626875fc","repo":"XTLS/Xray-core","slug":"select-padding-profile-w","errorCode":null,"errorMessage":"select padding profile: %w","messagePattern":"select padding profile: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"transport/internet/finalmask/xmc/client.go","lineNumber":53,"sourceCode":"}\n\ntype clientState int\n\nvar (\n\tclientStateHandshake clientState = 1\n\tclientStateProxy     clientState = 2\n)\n\nfunc newClientConn(c net.Conn, profiles []loginProfile, password string, rsaPublicKey []byte, hostname string) (*clientConn, error) {\n\tif len(rsaPublicKey) == 0 {\n\t\treturn nil, fmt.Errorf(\"empty rsa public key\")\n\t}\n\tif len(profiles) == 0 {\n\t\treturn nil, fmt.Errorf(\"empty profiles\")\n\t}\n\tpaddingSchedule, err := newClientPaddingSchedule2612()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"select padding profile: %w\", err)\n\t}\n\treturn &clientConn{\n\t\treader:          bufio.NewReader(c),\n\t\twriter:          c,\n\t\tc:               c,\n\t\tstate:           clientStateHandshake,\n\t\thandshakeLock:   sync.Mutex{},\n\t\tprofiles:        profiles,\n\t\tpassword:        password,\n\t\trsaPublicKey:    rsaPublicKey,\n\t\thostname:        hostname,\n\t\tpaddingSchedule: paddingSchedule,\n\t\tdeadlines:       newConnectionDeadlines(c),\n\t}, nil\n}\n\nfunc (c *clientConn) handshake() error {\n\tc.handshakeLock.Lock()","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/transport/internet/finalmask/xmc/client.go#L35-L71","documentation":"Wraps any error from newClientPaddingSchedule2612, which selects the wire-format padding schedule for the client connection. The %w means the underlying cause is chained; the schedule construction depends on built-in profile data, so failure indicates an internal inconsistency rather than user input.","triggerScenarios":"newClientPaddingSchedule2612 returning an error during connection construction, e.g. after the built-in 2612 padding profile table was modified or corrupted between versions. Not triggered by network conditions or remote peers.","commonSituations":"Mixing compiled artifacts from different transport versions; a patched build with an invalid padding profile table. Effectively unreachable on stock builds.","solutions":["Rebuild/reinstall so all transport packages come from one consistent version.","Inspect the chained error (unwrap %w) to see which profile entry failed.","Report upstream if it reproduces on an unmodified build."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"cc, err := newClientConn(conn, profiles, password, rsaKey, hostname)\nif err != nil {\n\tvar ppErr *paddingProfileError // if the library exposes typed causes\n\tif errors.As(err, &ppErr) {\n\t\treturn fmt.Errorf(\"inconsistent transport build: %w; rebuild from one version\", err)\n\t}\n\treturn err\n}","preventionTips":["Build all transport packages from a single version/commit.","Unwrap chained errors to identify internal vs. network causes before retrying."],"tags":["xmc","finalmask","internal-invariant","wrapped-error"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}