gtema / openstack

OpenStack SDK and CLI for Rust
https://gtema.github.io/openstack/
Apache License 2.0
22 stars 3 forks source link

Error on listing network subnet-pool #421

Closed joek-office closed 3 months ago

joek-office commented 3 months ago

Hello facing following error with version 0.6.4. joek@NB-1217-CLOUD ~ % osc --os-cloud os-internal.cloud --pretty network subnet-pool list Error: 0: Serializing Json data list into the table failed. Try using -o json to still see the raw data. 1: invalid type: string "64", expected i32

Location: openstack_cli/src/bin/osc.rs:43

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it. Run with RUST_BACKTRACE=full to include source snippets.

Consider reporting this error using this URL: https://github.com/gtema/openstack/issues/new?title=%3Cautogenerated-issue%3E&body=%23%23+Error%0A%60%60%60%0AError%3A+%0A+++0%3A+Serializing+Json+data+list+into+the+table+failed.+Try+using+%60-o+json%60+to+still+see+the+raw+data.%0A+++1%3A+invalid+type%3A+string+%2264%22%2C+expected+i32%0A%60%60%60%0A%0A%23%23+Metadata%0A%7Ckey%7Cvalue%7C%0A%7C--%7C--%7C%0A%7C**version**%7C0.6.4%7C%0A

with option --json the output is clear and no error occur.

gtema commented 3 months ago

The -o json is precisely to be able to handle such "unexpected" situations. In this particular case the error is an integer overflow compared to the data schema in neutron. It requires changes in codegerator. Will check tomorrow.

gtema commented 3 months ago

Ah, the error says pretty much that the string is received where integer was expected. Can you please check which field is it (in the '-o json' output)?

joek-office commented 3 months ago

See the problem. the json response (a bit shortened) looks like this:

[
  {
    "address_scope_id": null,
    "created_at": "2024-04-17T09:48:14Z",
    "default_prefixlen": "64",
    "default_quota": null,
    "description": "",
    "id": "36890564....",
    "ip_version": 6,
    "is_default": true,
    "max_prefixlen": "64",
    "min_prefixlen": "64",
    "name": "EXT-NETv6",
    "prefixes": [
      "::/48"
    ],
    "project_id": "002f3fe3...",
    "revision_number": 0,
    "shared": true,
    "tags": [],
    "tenant_id": "002f3fe3...",
    "updated_at": "2024-04-17T09:48:14Z"
  },
    ....
    ....
    ....
]

So in my opinion the following return values can be the error cause: max_prefixlen, min_prefixlen and default_prefixlen unfortunately it's not possible to restrict the output, but i think the error occurs in parsinf the response from api, so limiting output of fields will not solve any problem.

gtema commented 3 months ago

yeah, the __prefixlen is something I added recently without being able to see real values and assumed those are integers

gtema commented 3 months ago

https://docs.openstack.org/api-ref/network/v2/index.html#subnet-pools-extension-subnetpools is fun: in the parameter description it states it is integer, but in the example it is a string

gtema commented 3 months ago

This one appears to be not so trivial, because with the schema like in many other cases behaviour is a bit different, I am still on it on the codegerator side

gtema commented 3 months ago

I would appreciate if you can test artifact built in https://github.com/gtema/openstack/actions/runs/10317583003?pr=424 to see whether the issue is gone. As I mentioned above this is a bit tricky case but the newly generated code seems to be the correct to handle this situation (it will actually handle both int and string in the response)

joek-office commented 3 months ago

Seems that the error is walked a bit down the road ;-)

~/.cargo/bin/osc --os-cloud os-internal.cloud --pretty network subnet-pool list
Error: 
   0: Serializing Json data list into the table failed. Try using `-o json` to still see the raw data.
   1: invalid type: integer `6`, expected a string

Location:
   openstack_cli/src/bin/osc.rs:43

Seems like same error but on different field: ip_version

here is the json output:

[
  {
    "address_scope_id": null,
    "created_at": "2024-04-17T09:48:14Z",
    "default_prefixlen": "64",
    "default_quota": null,
    "description": "",
    "id": "3689056....",
    "ip_version": 6,
    "is_default": true,
    "max_prefixlen": "64",
    "min_prefixlen": "64",
    "name": "EXT-NETv6-Pool",
    "prefixes": [
      "....::/48"
    ],
    "project_id": "002f3fe3....",
    "revision_number": 0,
    "shared": true,
    "tags": [],
    "tenant_id": "002f3fe3...",
    "updated_at": "2024-04-17T09:48:14Z"
  },
  {
    "address_scope_id": null,
    "created_at": "2024-08-12T15:43:50Z",
    "default_prefixlen": "30",
    "default_quota": null,
    "description": "",
    "id": "9182a005...",
    "ip_version": 4,
    "is_default": false,
    "max_prefixlen": "30",
    "min_prefixlen": "24",
    "name": "MaintenanceInterconnect_1_SP_1",
    "prefixes": [
      "10.6.0.0/16"
    ],
    "project_id": "59e74....",
    "revision_number": 0,
    "shared": false,
    "tags": [],
    "tenant_id": "59e74.....",
    "updated_at": "2024-08-12T15:43:50Z"
  }
]

Just a small disclaimer. I dont know if i have used the correct version of osc. i have downloaded the zip file from the referenced pipeline artifacts and replaced the osc file in $HOME/.cargo/bin/ with the file from the downloaded zip file. The version is 0.6.4 like official one. If this is not correct please instruct me what to do.

gtema commented 3 months ago

yep, this is right. Anyway thanks a lot, this helps me. Perhaps I need to reconsider the functional test for this resource

gtema commented 3 months ago

https://github.com/gtema/openstack/actions/runs/10370038780 should help you. I have created subnetpool in one of the envs and to verify create/list work (in that env ;-)

joek-office commented 3 months ago

have tested around with subnetpool. Looks like all is working fine now. Thank you very much for the support.