request.cf.botManagement.score not working

request.cf.botManagement.score not working after building from ts? I dont use ts much so i have no idea why this is happening:
`"exceptions": [
{
"name": "TypeError",
"message": "Cannot read properties of undefined (reading 'score')",
"timestamp": 1691488611986
}
],

`"exceptions": [
{
"name": "TypeError",
"message": "Cannot read properties of undefined (reading 'score')",
"timestamp": 1691488611986
}
],

I tried it again in vanilla and it does not work there either, I had it working yesterday and got the 99 score, I'm unsure what changed today to make it non functional
export default {
async fetch(request, env, ctx) {
return new Response(`score: ${request.cf.botManagement.score}`);
},
};
export default {
async fetch(request, env, ctx) {
return new Response(`score: ${request.cf.botManagement.score}`);
},
};
6 Replies
Chaika
Chaika16mo ago
hmm, how are you running/testing this? On a deployed worker? It may be worth noting that it's just a placeholder unless you are Enterprise with Bot Management addon, it'll always be 99. It was just kept to not break tests internally iirc
Dahoom4030
Dahoom4030OP16mo ago
i guess it was that, I'm not on enterprise
Chaika
Chaika16mo ago
oh it looks like the placeholder is not on requests to workers.dev, only for requests to custom domains, as well, But yea, it'd be useless for you eitherway without the Ent addon
Dahoom4030
Dahoom4030OP16mo ago
Thank you
Chaika
Chaika16mo ago
It turns out it's a bit more complex then I thought: Here's a full story: CF accidentally gave Bot management via the cf.botManagement field to everyone, they removed it (opps!), and broke things. So they added it back in with dummy values. It turns out, now, as of August 1st, they are defaulting (via Worker compat dates) to removing it again. If your Worker compat date is greater then August 1st, like if you deployed from dash, you'll default to it being gone. You can set the compat flag cf_botmanagement_default to have it back. If you are before that compat date and want to disable it, you can set the compat flag no_cf_botmanagement_default Most likely the worker you were testing before had a compat date before August 1st
Dahoom4030
Dahoom4030OP16mo ago
that makes a lot of sense
Want results from more Discord servers?
Add your server