Fix more UME split regressions for sync and alarm WSS.

Restore sql_text and alarm-apply imports, slim WSS handshake headers to accessToken only, and treat 404/503 handshakes as lost subscriptions.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-06 15:59:02 +08:00
parent 4054f55988
commit c91d1571a2
4 changed files with 9 additions and 2 deletions

View file

@ -29,6 +29,8 @@ from .ume_alarm_ws_subscription import (
from .ume_client import UMEClient
from .ume_sync_service import (
_alarm_key,
_utc_now_naive,
apply_alarm_to_current,
extract_alarm_from_notification,
normalize_yang_alarm,
)

View file

@ -23,6 +23,9 @@ _SUBSCRIPTION_MISSING_MARKERS: tuple[str, ...] = (
"status-code: 404",
"status-reason: subscription not found",
"non-101 status: 503",
"non-101 status: 404",
"handshake status 404",
"handshake status 503",
)

View file

@ -656,10 +656,11 @@ class UMEClient:
def ws_auth_headers(self) -> dict[str, str]:
"""
Headers for WSS handshake — same fields as REST (_headers).
Headers for WSS handshake — accessToken only (no REST content-type).
Does not login/renew; relies on shared token store (token_keepalive / other sync paths).
"""
self._sync_token_from_store()
if not self.has_valid_token():
raise RuntimeError("ume_ws_no_valid_token")
return self._headers(include_token=True)
token = self._token_value.strip()
return {self.auth_header: token}

View file

@ -4,6 +4,7 @@ from __future__ import annotations
from datetime import datetime
from typing import Any
from sqlalchemy import text as sql_text
from sqlalchemy.orm import Session
from .models import UmeAlarmCurrent, UmeAlarmHistory, UmeInventoryNE