cloudflare / cloudflare-rs

Rust library for the Cloudflare v4 API
255 stars 81 forks source link

ListZones not work due to deserialize json fail! #198

Open derust opened 1 year ago

derust commented 1 year ago
        let req = ListZones { params };
        let resp: Vec<Zone> = self.api_client.request_handle(&req).await?.result;
      //this fail with: error decoding response body: invalid type: null, expected a string at line 1 column 615)

parse fail happens at this line ListZones

        let parsed: Result<ApiSuccess<ResultType>, reqwest::Error> = resp.json();

the response json which fail to be parsed

{
    "result": [
        {
            "id": "xxxxxxxxxxxxxxxxxxx",
            "name": "xxxx.com",
            "status": "active",
            "paused": false,
            "type": "full",
            "development_mode": 0,
            "name_servers": [
                "frank.ns.cloudflare.com",
                "sandy.ns.cloudflare.com"
            ],
            "original_name_servers": null,
            "original_registrar": "name.com, inc. (id: 625)",
            "original_dnshost": null,
            "modified_on": "2021-11-12T21:01:17.744476Z",
            "created_on": "2020-11-18T10:40:49.839936Z",
            "activated_on": "2020-11-18T10:43:07.087867Z",
            "meta": {
                "step": 2,
                "custom_certificate_quota": 0,
                "page_rule_quota": 3,
                "phishing_detected": false,
                "multiple_railguns_allowed": false
            },
            "owner": {
                "id": null,
                "type": "user",
                "email": null
            },
            "account": {
                "id": "xxxxxxxxxxxxxxxxxxxx",
                "name": "xxxxxxxxxxxxx"
            },
            "tenant": {
                "id": null,
                "name": null
            },
            "tenant_unit": {
                "id": null
            },
            "permissions": [
                "#access:edit",
                "#access:read",
                "#analytics:read",
                "#app:edit",
                "#auditlogs:read",
                "#billing:edit",
                "#billing:read",
                "#blocks:edit",
                "#blocks:read",
                "#cache_purge:edit",
                "#dash_sso:edit",
                "#dash_sso:read",
                "#dns_records:edit",
                "#dns_records:read",
                "#fbm_acc:edit",
                "#fbm:edit",
                "#fbm:read",
                "#healthchecks:edit",
                "#healthchecks:read",
                "#http_applications:edit",
                "#http_applications:read",
                "#image:edit",
                "#image:read",
                "#lb:edit",
                "#lb:read",
                "#legal:edit",
                "#legal:read",
                "#logs:edit",
                "#logs:read",
                "#magic:edit",
                "#magic:read",
                "#member:edit",
                "#member:read",
                "#organization:edit",
                "#organization:read",
                "#ssl:edit",
                "#ssl:read",
                "#stream:edit",
                "#stream:read",
                "#subscription:edit",
                "#subscription:read",
                "#teams:edit",
                "#teams:pii",
                "#teams:read",
                "#teams:report",
                "#waf:edit",
                "#waf:read",
                "#waitingroom:edit",
                "#waitingroom:read",
                "#webhooks:edit",
                "#webhooks:read",
                "#worker:edit",
                "#worker:read",
                "#zaraz:edit",
                "#zaraz:publish",
                "#zaraz:read",
                "#zone:edit",
                "#zone:read",
                "#zone_settings:edit",
                "#zone_settings:read",
                "#zone_versioning:edit",
                "#zone_versioning:read"
            ],
            "plan": {
                "id": "0feeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                "name": "Free Website",
                "price": 0,
                "currency": "USD",
                "frequency": "",
                "is_subscribed": false,
                "can_subscribe": false,
                "legacy_id": "free",
                "legacy_discount": false,
                "externally_managed": false
            }
        }
    ],
    "result_info": {
        "page": 1,
        "per_page": 20,
        "total_pages": 1,
        "count": 1,
        "total_count": 1
    },
    "success": true,
    "errors": [],
    "messages": []
}
Mange commented 1 year ago

I'm also having this problem.

Maintainers: Is there anything I can do to help get a fix out?

nrdxp commented 1 year ago

I am blocked by this as well now. Had a code base making API requests using reqwest manually and I refactored to use this crate instead. Now I cannot test as I got stuck here.

taladar commented 2 months ago

Judging by the value

     "owner": {
                "id": null,
                "type": "user",
                "email": null
            },

and the fact that I ran into the same issue just now this is likely a duplicate of #193