Skip to content

fix: XMuxSettings camelCase deserialization (xMux lost in VLESS links)#589

Open
Ieqzya wants to merge 1 commit into
PasarGuard:mainfrom
Ieqzya:fix/xmux-camelcase-deserialization
Open

fix: XMuxSettings camelCase deserialization (xMux lost in VLESS links)#589
Ieqzya wants to merge 1 commit into
PasarGuard:mainfrom
Ieqzya:fix/xmux-camelcase-deserialization

Conversation

@Ieqzya

@Ieqzya Ieqzya commented Jun 10, 2026

Copy link
Copy Markdown

Description

XMux settings in hosts.transport_settings silently lost. extra parameter in VLESS links never contains xmux.

Root Cause

serialization_alias in Pydantic v2 only affects output, not input. JSON camelCase keys not mapped to snake_case fields.

Fix

Replace serialization_alias with alias in XMuxSettings (6 fields).

Verification

Before: XMuxSettings({maxConcurrency: 8}).max_concurrency -> None
After: XMuxSettings(
{maxConcurrency: 8}).max_concurrency -> 8

Summary by CodeRabbit

  • Refactor
    • Updated how connection and reuse configuration settings are serialized and deserialized. This ensures consistent handling of these parameters in configuration exchanges.

serialization_alias in Pydantic v2 only affects output (model_dump),
not input parsing. When JSON from DB comes with camelCase keys
(maxConcurrency vs max_concurrency), the field silently resolves to None.

This breaks xmux in VLESS subscription links — xmux is parsed as None,
model_dump(exclude_none=True) returns {}, and _normalize_and_remove_none_values
strips the empty dict, removing xmux from the 'extra' parameter entirely.

Replace serialization_alias with alias, which in Pydantic v2 is used
for both validation and serialization, fixing the round-trip.
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b3725d07-895b-4bad-a830-2f5c2b11ada1

📥 Commits

Reviewing files that changed from the base of the PR and between 5155eac and 8658c12.

📒 Files selected for processing (1)
  • app/models/host.py

Walkthrough

This PR updates the XMuxSettings model in app/models/host.py to use Pydantic's bidirectional alias parameter instead of serialization_alias for six configuration fields. The change affects how camelCase external names are declared for model parsing and serialization.

Changes

XMuxSettings Field Aliasing

Layer / File(s) Summary
Update XMuxSettings field aliases to bidirectional mode
app/models/host.py
Six numeric configuration fields (max_concurrency, max_connections, c_max_reuse_times, h_max_reusable_secs, h_max_request_times, h_keep_alive_period) now declare their camelCase external names via alias instead of serialization_alias, enabling the names to be used during both model parsing and serialization rather than serialization only.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Six fields now speak in both directions true,
From camelCase in, to camelCase through,
Pydantic's alias, a bidirectional dance,
Parsing and serialization, given their chance!
XMuxSettings hops with renewed design ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the specific problem (XMuxSettings camelCase deserialization) and its impact (xMux lost in VLESS links), directly reflecting the main change in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant