Reading a worker's compatibility date

I see that one can set a worker's compatibility date from wrangler (and by extension the API, although it is not documented). Is there a way, instead, to just read the compatibility date? It is not displayed in the dashboard and I haven't seen an API route to fetch it. Thanks.
13 Replies
Yacine Hmito
Yacine HmitoOP2y ago
Same question for compatibility flags, by the way
Cyb3r-Jak3
Cyb3r-Jak32y ago
There is as the terraform provider does it. I can parse the code later to find the exact endpoint for it Never mind found it. Look at the api docs and where it has the depreciated bindings endpoint replace zone with accounts
Yacine Hmito
Yacine HmitoOP2y ago
Thank you very much ! @Cyb3r-Jok3 This doesn't give the compatibility date. I also dug in the Terraform Provider and it turns out that the compatibility date (and flags) are never read from the API. They are marked as both optional and computed. It's basically a write-only field.
Cyb3r-Jak3
Cyb3r-Jak32y ago
Optional means you don't need to set them and Computed means that they can be set by the API
Yacine Hmito
Yacine HmitoOP2y ago
From Terraform's documentation:
Computed is often used to represent values that are not user configurable or can not be known at time of terraform plan or apply
https://developer.hashicorp.com/terraform/plugin/sdkv2/schemas/schema-behaviors#computed They're the only 2 computed fields on a worker's deployment config. It basically means it is never read from the API. The handler to read the worker script resource also doesn't ever read nor write them So I am pretty confident that these fields are write-only
Cyb3r-Jak3
Cyb3r-Jak32y ago
Write-only I'm going to disagree on but yeah it does look like they are never read When you create or update a worker they are set https://github.com/cloudflare/terraform-provider-cloudflare/blob/master/internal/sdkv2provider/resource_cloudflare_workers_script.go#L170-L178
Yacine Hmito
Yacine HmitoOP2y ago
Isn't "write-only" and "never read" the same thing?
Cyb3r-Jak3
Cyb3r-Jak32y ago
It depends what you are refering to by write only. Do you mean something like they are never set locally by remote or they are only set by remote
Yacine Hmito
Yacine HmitoOP2y ago
I meant this is a field that can only be written and that can not be read, so write-only (as opposed to read-write or read-only) In any case, the question is about "How can I read the compatibility date / flags of a worker?". The conclusion seems to be "you can't".
Cyb3r-Jak3
Cyb3r-Jak32y ago
Yeah after reviewing the code, I was mistaken there is no documented way to read that info
Yacine Hmito
Yacine HmitoOP2y ago
No problem. How do I make sure that someone from Cloudflare sees this?
Cyb3r-Jak3
Cyb3r-Jak32y ago
You can post this as a feature suggestion in #workers-feature-suggestions
Yacine Hmito
Yacine HmitoOP9mo ago
It seems to have been solved with the introduction of Versions: https://developers.cloudflare.com/api/operations/worker-script-get-settings
Cloudflare API Documentation
Interact with Cloudflare's products and services via the Cloudflare API
Want results from more Discord servers?
Add your server