Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

🐛 cfRay is missing from proxied request logs (newHTTPLogger discards the zerolog context)

Open Beginner friendly
#1,756 0 comments 0 reactions 0 assignees View on GitHub

@pankajc46 is already working on this.

Since Oct 8, 2026.

  • #1757 by @pankajc46 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
observability

Research direction

Start in proxy/logger.go, in newHTTPLogger, where the cfRay and lbProbe context calls discard their return values. Assign the results back to ctx, then add a regression test in the proxy package that checks cfRay and lbProbe appear in the logged fields. Done when that test fails on the current code and passes with the change.

Written by the indexing model from the issue text.

Description

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:

  1. Run a tunnel with any HTTP ingress rule, with JSON logs to make the fields easy to see: cloudflared tunnel --output json run <TUNNEL>
  2. 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).
  3. Look at the "event":1 log line for that request: there is no cfRay field.

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/cloudflared container 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.

Dominant language
Go
Stars
16k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cloudflare/cloudflared

All issues in cloudflare/cloudflared

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.