Bug in flarectl, Cloudflare API docs, cloudflare-go and cloudflare-rs

https://developers.cloudflare.com/api/operations/zones-get Owner should always have email, id and type as strings, however my response was:
"owner": {
"email": null,
"id": null,
"type": "user"
},
"owner": {
"email": null,
"id": null,
"type": "user"
},
https://github.com/cloudflare/cloudflare-rs/blob/b4fa5ef8bb48415c54974ee3ed11cf9d8397d98b/cloudflare/src/endpoints/zone.rs#L111-L114
pub enum Owner {
User { id: String, email: String },
Organization { id: String, name: String },
}
pub enum Owner {
User { id: String, email: String },
Organization { id: String, name: String },
}
Rust API says that owner is either "user" (with id and email, both of which are always present) or "organization" (with id and name, both of which are always present). According to the api docs, email should never be present
Cloudflare API Documentation
Interact with Cloudflare's products and services via the Cloudflare API
GitHub
cloudflare-rs/cloudflare/src/endpoints/zone.rs at b4fa5ef8bb48415c5...
Rust library for the Cloudflare v4 API. Contribute to cloudflare/cloudflare-rs development by creating an account on GitHub.
11 Replies
Thoumas
ThoumasOP•11mo ago
Something is definitely wrong here. 1. Docs should include email (or make the owner field a variant that is either of type "user" or type "organization") 2. Maybe there is a bug in the API making it return nulls for the owner's email and id 3. If there isn't a bug in the API, then the docs and the Rust enum should reflect that these fields are optional
kian
kian•11mo ago
Other than cloudflare-go, I'd say that the SDKs aren't maintained so I doubt it'll be fixed any time soon (if there is an issue with it)
Thoumas
ThoumasOP•11mo ago
Should also be a problem with the go implementation but I'm not sure (not proficient in go). Either way the docs should include email. https://github.com/cloudflare/cloudflare-go/blob/master/zone.go#L24-L29
type Owner struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
OwnerType string `json:"type"`
}
type Owner struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
OwnerType string `json:"type"`
}
EDIT: just checked the go implementation and the result ends up being {"id":"","email":"","name":"","type":"user"}
Thoumas
ThoumasOP•11mo ago
I installed flarectl just like the README (https://github.com/cloudflare/cloudflare-go/tree/master/cmd/flarectl) told me to (go install github.com/cloudflare/cloudflare-go/cmd/flarectl@latest) to investigate this issue and the zone command wouldn't run since the alias for create and cert were the same. Had to delete the following to get it to work:
diff --git a/cmd/flarectl/flarectl.go b/cmd/flarectl/flarectl.go
index 9afbd15..f89071d 100644
--- a/cmd/flarectl/flarectl.go
+++ b/cmd/flarectl/flarectl.go
@@ -225,7 +225,6 @@ func main() {
},
{
Name: "certs",
- Aliases: []string{"c"},
Action: zoneCerts,
Usage: "Custom SSL certificates for a zone",
},
diff --git a/cmd/flarectl/flarectl.go b/cmd/flarectl/flarectl.go
index 9afbd15..f89071d 100644
--- a/cmd/flarectl/flarectl.go
+++ b/cmd/flarectl/flarectl.go
@@ -225,7 +225,6 @@ func main() {
},
{
Name: "certs",
- Aliases: []string{"c"},
Action: zoneCerts,
Usage: "Custom SSL certificates for a zone",
},
After applying my patch and running flarectl zone list I got my zone id and then I ran flarectl zone info --zone myzoneid which gave me this:
ID | ZONE | PLAN | STATUS | NAME SERVERS | PAUSED | TYPE
-----+------+------+--------+--------------+--------+-------
ID | ZONE | PLAN | STATUS | NAME SERVERS | PAUSED | TYPE
-----+------+------+--------+--------------+--------+-------
GitHub
cloudflare-go/cmd/flarectl at master · cloudflare/cloudflare-go
Go library for the Cloudflare v4 API. Contribute to cloudflare/cloudflare-go development by creating an account on GitHub.
Thoumas
ThoumasOP•11mo ago
will do as soon as I find out why the info command doesn't work
Thoumas
ThoumasOP•11mo ago
GitHub
flarectl: fix duplicate alias in zone subcommand by thomasqueirozb ...
Fixes: #1465 Description check and certs were both aliased to "c". Changed certs alias from "c" to "ct". This would've been way more easier to debug if a log were ...
Thoumas
ThoumasOP•11mo ago
I messed up. The flarectl zone info command works with the zone name not the id. Just wasted an hour 🙂
Thoumas
ThoumasOP•11mo ago
Created a PR "fixing" this in the rust implementation but I doubt it will be merged anytime soon 😦 https://github.com/cloudflare/cloudflare-rs/pull/232
GitHub
zone: make Owner have default values by thomasqueirozb · Pull Reque...
According to the docs id and name are not required and email isn't even mentioned. My request had id and email as null, which broke deserialization "owner": { "id": nu...
Thoumas
ThoumasOP•11mo ago
Docs are still wrong but idk how I'd even report that
Cyb3r-Jak3
Cyb3r-Jak3•11mo ago
There is a feedback button in the bottom left on the api docs page to report these type of issues
Want results from more Discord servers?
Add your server