Skip to content

fix(cisco/meraki): Client.vlan is now a String not Int32#270

Merged
w-le merged 1 commit into
masterfrom
fix/meraki/models
Nov 18, 2021
Merged

fix(cisco/meraki): Client.vlan is now a String not Int32#270
w-le merged 1 commit into
masterfrom
fix/meraki/models

Conversation

@w-le
Copy link
Copy Markdown
Contributor

@w-le w-le commented Nov 18, 2021

Cisco have updated the Meraki Dashboard API and it appears Client.vlan is now a String instead of an Int.
I see no mention of that specific change online like here or anything https://community.meraki.com/t5/Developers-APIs/Dashboard-API-Fall-2021-Feature-Announcements-What-s-new/td-p/132555
and their docs online still state that client.vlan is an Int
"vlan": 255,
https://developer.cisco.com/meraki/api-v1/#!get-network-clients

On 3 of 3 meraki instances I have confirmed errors like:
Couldn't parse (Int32 | Nil) from \"153\" ... parsing Cisco::Meraki::Client#vlan

module_name": "MerakiLocations",
    "index": 1,
    "message": "module raised: remote exception: Couldn't parse (Int32 | Nil) from \"153\" at line 1, column 508\n  parsing Cisco::Meraki::Client#vlan at line 1, column 501 (JSON::SerializableError) (PlaceOS::Driver::RemoteException) (PlaceOS::Driver::RemoteException)",
    "backtrace": [
        "/usr/share/crystal/src/json/serialization.cr:159:7 in 'initialize:__pull_for_json_serializable'",
        "repositories/drivers/drivers/cisco/meraki/scanning_api.cr:103:5 in 'new_from_json_pull_parser'",
        "repositories/drivers/drivers/cisco/meraki/scanning_api.cr:103:5 in 'new'",
        "/usr/share/crystal/src/json/from_json.cr:153:11 in 'new'",
        "/usr/share/crystal/src/json/from_json.cr:13:3 in 'from_json'",
        "repositories/drivers/drivers/cisco/meraki/dashboard.cr:145:22 in 'poll_clients'",
    "module_name": "MerakiLocations",
    "index": 1,
    "message": "module raised: remote exception: Couldn't parse (Int32 | Nil) from \"502\" at line 1, column 421\n  parsing Cisco::Meraki::Client#vlan at line 1, column 414 (JSON::SerializableError) (PlaceOS::Driver::RemoteException) (PlaceOS::Driver::RemoteException)",
    "backtrace": [
        "/usr/share/crystal/src/json/serialization.cr:159:7 in 'initialize:__pull_for_json_serializable'",
        "repositories/drivers/drivers/cisco/meraki/scanning_api.cr:52:5 in 'new_from_json_pull_parser'",
        "repositories/drivers/drivers/cisco/meraki/scanning_api.cr:52:5 in 'new'",
        "/usr/share/crystal/src/json/from_json.cr:153:11 in 'new'",
        "/usr/share/crystal/src/json/from_json.cr:13:3 in 'from_json'",
        "repositories/drivers/drivers/cisco/meraki/dashboard.cr:114:24 in 'poll_clients'",

On 3 of 3 meraki instances I have confirmed errors like: Couldn't parse (Int32 | Nil) from \"153\" ... parsing Cisco::Meraki::Client#vlan
@w-le w-le requested a review from stakach November 18, 2021 08:45
@w-le w-le self-assigned this Nov 18, 2021
@w-le w-le added the type: bug something isn't working label Nov 18, 2021
@w-le w-le merged commit 1cd61b1 into master Nov 18, 2021
@w-le
Copy link
Copy Markdown
Contributor Author

w-le commented Nov 18, 2021

fix confirmed working e2e.
This means that the Cisco meraki api documentation is currently incorrect / out of date

@w-le w-le deleted the fix/meraki/models branch November 18, 2021 08:58
@caspiano
Copy link
Copy Markdown
Contributor

If you want to preserve the Int32 type, you can copy this little utility I wrote for a string typed API

https://github.com/place-labs/crystal-etcd/blob/master/src/etcd/model/base.cr#L33-L41

Essentially would be used as follows

  @[JSON::Field(converter: StringTypeConverter(Int32))]
  getter vlan : Int32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: critical type: bug something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants