#Validating Ray ID

13 messages · Page 1 of 1 (latest)

pearl gyro
#

Am working on a PR to forward the Cf-Ray value for a logging context, but would like to be able to validate the value I receive first. Any assistance would be appreciated.

#

For example if Cf-Ray is 230b030023ae2822-SJC will it consistently be structured like this and contain as many characters as this?

heady rivet
#

No, the structure isn't guaranteed to that degree and if you rely on it then your application may break years down the line

pearl gyro
#

OK. Do you potentially have a suggestion as to how I can verify that the value is indeed a valid Ray ID provided by CF?

heady rivet
#

I dont believe you can, unless you have an Enterprise product like http logpush setup on the zone to do a rayid lookup in (but even then you'd hardly be able to do it for every single request)

#

Is your code going to be running in the request/response flow of some website, like a web server or such?

pearl gyro
#

OK, that's informative.

#

SaaS application, yes

heady rivet
#

If the request comes from a Cloudflare IP address then it's probably reasonable to assume the ray id is correct

pearl gyro
#

Ah, that could be a good combination. Thank you Erisa!

alpine basalt
#

The above is correct, but I'll add - there isn't really such a thing as an "invalid" ray ID, it's more or less just an integer. It has no real meaning beyond being something you can find in logs, if any logs exist.

white topaz
#

230b030023ae2822-SJC is the funnest looking integer ive ever seen (yes I know)