`cf.asOrganization` is `undefined` for some requests
Ran into this in production today where
req.cf.asOrganization was undefined for some requests.
The IncomingRequestCfProperties docs show this as being a string and not optional.
Was able to fix the issue by changing our code (which is based on worker-sys) to treat the property as optional:
Was going to contribute this back to worker-sys, but when I consulted the docs and saw that it is denoted as non-optional I wanted to see whether this is expected to always be present.
And if cf.asOrganization is always intended to be there, why is it missing from some requests?4 Replies
It can be optional, do not rely on it existing
Okay, so should the docs be updated to reflect that?
yes they should be, a lot of the geo-ip and ip-related info can be optional as we may not always have it
I went ahead and opened a PR to upstream the fix to the
worker crate: https://github.com/cloudflare/workers-rs/pull/776GitHub
Make
as_organization optional on IncomingRequestCfProperties by...This PR updates the IncomingRequestCfProperties to reflect that as_organization is optional.
We ran into a case today in production where cf.asOrganization was undefined.
We're not using wo...