fix: address PR #814 reviewer follow-ups
- gateway_client: guard token cache with a lazy anyio.Lock so concurrent embed calls share one M2M token request instead of racing - status subscriber: distinguish idle fetch timeouts from real broker errors (log + 5s backoff) instead of swallowing all and spinning - nats: warn when the bus URL uses unencrypted transport (non-tls://) - collection_metadata: accept an optional shared httpx client, make TLS verify explicit, document the unauthenticated control-plane contract - replace python -O-stripped asserts with explicit ValueError in the bus status builder and the api metadata source - document why the nil-UUID sentinel point can't collide with content ids Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
b5ed1e3b4d
commit
2d845cb70f
@@ -29,6 +29,22 @@ STREAM_NAME = "mcp"
|
||||
INGEST_SUBJECT_PREFIX = "mcp.ingest.requested"
|
||||
|
||||
|
||||
def warn_if_insecure_nats_url(url: str) -> None:
|
||||
"""Log a warning when the bus URL is not TLS-encrypted.
|
||||
|
||||
``nats://`` (and ``ws://``) carry tenant document metadata in cleartext;
|
||||
production deployments should use ``tls://`` (or ``wss://``). We connect
|
||||
regardless — this is an operator alert, not a hard failure.
|
||||
"""
|
||||
scheme = url.split("://", 1)[0].lower()
|
||||
if scheme not in ("tls", "wss"):
|
||||
logger.warning(
|
||||
"NATS bus URL uses unencrypted transport (scheme=%s://); "
|
||||
"use tls:// in production to protect document metadata in transit",
|
||||
scheme,
|
||||
)
|
||||
|
||||
|
||||
def _modified_at_rfc3339(modified_at: int) -> str:
|
||||
"""DocumentTask.modified_at is an epoch int (0 for deletes)."""
|
||||
return datetime.fromtimestamp(int(modified_at), tz=timezone.utc).isoformat()
|
||||
@@ -74,6 +90,7 @@ class NatsTaskProducer:
|
||||
) -> NatsTaskProducer:
|
||||
import nats # noqa: PLC0415 (lazy: optional dependency for external mode)
|
||||
|
||||
warn_if_insecure_nats_url(url)
|
||||
nc = await nats.connect(url)
|
||||
js = nc.jetstream()
|
||||
await cls._ensure_stream(js, num_replicas)
|
||||
|
||||
Reference in New Issue
Block a user