Skip to content

[Bug] Hysteria subscription generation fails when udpHop is None #987

Closed

Description

@peppa-pigfarm

Before you submit

  • I searched existing issues and did not find the same problem.
  • I am using the latest available PasarGuard version, or I included the exact version below.

PasarGuard version

v5.4.1

Installation type

Docker

What happened?

[Bug] Hysteria subscription generation fails when udpHop is None

Description

Hysteria subscription generation fails with an AttributeError when the optional udpHop field is not configured in FinalMask.

In the FinalMaskQuicParams Pydantic model, udpHop defaults to None. However, the subscription generators expect it to be a dictionary.

Error

The issue occurs in both links.py and clash.py.

links.py (line 327):

payload["mports"] = quic_params.get("udpHop", {}).get("ports", "")

clash.py (line 697):

node["ports"] = quic_params.get("udpHop", {}).get("ports", "")

Both can raise:

AttributeError: 'NoneType' object has no attribute 'get'

Root Cause

When a FinalMask Pydantic model is serialized using:

finalmask.model_dump(by_alias=True)

Optional fields with None values are included in the resulting dictionary.

For example:

{
    "quicParams": {
        "udpHop": None
    }
}

Calling .get("udpHop", {}) returns None because the key exists, even though its value is None.

Suggested Fix

Option 1: Exclude None values during serialization:

finalmask.model_dump(by_alias=True, exclude_none=True)

Option 2: Safely handle None values in subscription generators:

payload["mports"] = (quic_params.get("udpHop") or {}).get("ports") or ""
node["ports"] = (quic_params.get("udpHop") or {}).get("ports") or ""

Expected Behavior

Hysteria subscription generation should succeed when udpHop is not configured, without raising an exception.

Actual Behavior

Subscription generation fails with AttributeError when udpHop is None.

Steps to reproduce

  1. enable "disablePathMTUDiscovery" in hysteria finalmask (quic)
  2. reload subscription by url

Expected behavior

Hysteria subscription generation should work correctly when the optional udpHop field is missing or set to None.

Since udpHop is optional, subscription generators should handle its absence gracefully instead of raising an AttributeError.

Both links.py and clash.py should generate valid Hysteria configurations without requiring udpHop to be explicitly configured.

Logs and error messages

**Error in `links.py`:**

File "/code/app/subscription/links.py", line 327, in _build_hysteria
    payload["mports"] = quic_params.get("udpHop", {}).get("ports", "")
AttributeError: 'NoneType' object has no attribute 'get'


**Error in `clash.py`:**

File "/code/app/subscription/clash.py", line 697, in _build_hysteria
    node["ports"] = quic_params.get("udpHop", {}).get("ports", "")
AttributeError: 'NoneType' object has no attribute 'get'


**Cause:**

The optional `udpHop` field is `None`, but both subscription generators attempt to call `.get("ports")` on it.

Environment

OS: Linux
Database: PostgreSQL

Relevant configuration

Screenshots or videos

No response

Additional context

No response

Activity

  1. added
    bug
    on Oct 9, 2026
  2. changed the title [-][Bug]:[/-] [+][Bug] Hysteria subscription generation fails when udpHop is None[/+] on Oct 9, 2026
  3. T3ST3ST3R0N commented on Oct 10, 2026

    @T3ST3ST3R0N
    Collaborator

    Thanks for the detailed report. The case you described is fixed on dev by #974, and #993 fixes the remaining shapes (a Hysteria FinalMask with quicParams but no udp mask). Both ship in the next release.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions