🐛 cfRay is missing from proxied request logs (newHTTPLogger discards the zerolog context)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go
- Lĩnh vực
- observability
Hướng nghiên cứu
Bắt đầu từ proxy/logger.go, trong newHTTPLogger, nơi các lệnh gọi cfRay và lbProbe bỏ qua giá trị trả về. Gán lại kết quả vào ctx, sau đó thêm một bài kiểm thử hồi quy trong gói proxy để kiểm tra rằng cfRay và lbProbe xuất hiện trong các trường được ghi log. Hoàn thành khi bài kiểm thử đó thất bại với mã hiện tại và đạt với thay đổi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
The per-request log lines emitted by the proxy never include the cfRay field (nor lbProbe for load balancer health probes), even when the request carries a Cf-Ray header. This affects the origin request error line (logRequestError) and the debug request/response lines (logHTTPRequest / logOriginHTTPResponse), so a cloudflared log line can't be correlated with the same request in Cloudflare's edge logs (Logpush RayID) or in origin access logs.
Root cause: newHTTPLogger in proxy/logger.go calls ctx.Str / ctx.Bool without assigning the result. zerolog.Context methods have value receivers and return the updated context, so both fields are dropped:
if cfRay != "" {
ctx.Str(logFieldCFRay, cfRay) // returned context is discarded
}
if lbProbe {
ctx.Bool(logFieldLBProbe, lbProbe) // returned context is discarded
}
https://github.com/cloudflare/cloudflared/blob/2026.10.0/proxy/logger.go#L35-L40
This came in with 971360d5e0b97c41f1cffd4b79c79a05e6a5e91b (TUN-8238: Refactor proxy logging), first released in 2024.2.1. Before that, the same error line did include it, e.g. in #1012: error="Incoming request ended abruptly: context canceled" cfRay=7e0bcd892f8d4dc8-SIN event=1 originService=....
To Reproduce
Steps to reproduce the behavior:
- Run a tunnel with any HTTP ingress rule, with JSON logs to make the fields easy to see:
cloudflared tunnel --output json run <TUNNEL> - Send a request through the tunnel that fails at the origin (for example, a client that disconnects before the origin responds, or an ingress rule pointing at a port with nothing listening).
- Look at the
"event":1log line for that request: there is nocfRayfield.
With --loglevel debug, the "event":1 request and response lines are missing cfRay as well.
If it's an issue with Cloudflare Tunnel:
4. Tunnel ID : not tunnel-specific, reproducible with any tunnel
5. cloudflared config: any HTTP ingress rule
Expected behavior
Per-request log lines include "cfRay":"<ray id>" (and "lbProbe":true for load balancer health probes), as newHTTPLogger intends.
Environment and versions
- OS: Linux (Kubernetes,
cloudflare/cloudflaredcontainer image) - Architecture: AMD64 and ARM64
- Version: 2026.10.0 (affects every release since 2024.2.1)
Logs and errors
Origin request error line from 2026.10.0 (hostname anonymised):
{"connIndex":1,"error":"Incoming request ended abruptly: context canceled","event":1,"ingressRule":9,"level":"error","originService":"https://origin.example.com","time":"2026-10-08T09:44:53Z"}
connIndex, originService and ingressRule from the same logger context are present; cfRay is not.
Additional context
The fix is a two-line change (ctx = ctx.Str(...) / ctx = ctx.Bool(...)). I'll open a PR with it and a regression test that fails on master and passes with the change.
- Ngôn ngữ chính
- Go
- Star
- 16.2k
- Fork
- 1.5k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của cloudflare/cloudflared
-
🐛 --output json writes invalid JSON lines when events are logged concurrentlyCó thể đã có người làm @theolujay đã nhận 11 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
cloudflare/cloudflared#1761 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
🐛 After SIGTERM, `cloudflared tunnel run` uses 100% of one CPU core for the whole graceful-shutdown periodCó thể đã có người làm @cyphercodes đã nhận 13 ngày trước. Đang mởPriority: Normal Type: Bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
cloudflare/cloudflared#1753 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
tunnel route ip show: --filter-network-is-subset-of sends the superset filterCó thể đã có người làm @wangyusheng1985 đã nhận 13 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
cloudflare/cloudflared#1750 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
🐛 QUIC Hijack() skips the status-written check that HTTP/2 enforcesCó thể đã có người làm @dedsec-terminal đã nhận 7 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
cloudflare/cloudflared#1748 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
🐛 QUIC Hijack() skips the status-written check that HTTP/2 enforcesCó thể đã có người làm @Asthenia0412 đã nhận 24 ngày trước. Đang mởPriority: Normal Type: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
cloudflare/cloudflared#1747 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của cloudflare/cloudflared
Issue tương tự
-
Mend: dependency security vulnerability
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
kube-tarian/sigrun#202 ·
-
question raised-by:verifier
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
medici-finance/assay#4013 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
TestRegistry_ConcurrentMixedOperations fetches from the network and can hang the short suiteĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
tsukumogami/tsuku#2775 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
automation models
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
Maintainer thường phản hồi trong vòng 1 ngày