[GH-ISSUE #20] Error during device listing #9

Closed
opened 2026-02-27 20:22:34 +03:00 by kerem · 4 comments
Owner

Originally created by @kjedamzik on GitHub (Oct 6, 2018).
Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/20

I get an error when I try to:

let devices = spotify.device();
println!("{:?}", devices);
ErrorMessage { msg: "convert result failed, content \"{\\n  \\\"devices\\\" : [ {\\n    \\\"id\\\" : \\\"1b6e8429877f28aeb2f0af52567e9b9224319d3a\\\",\\n    \\\"is_active\\\" : false,\\n    \\\"is_private_session\\\" : false,\\n    \\\"is_restricted\\\" : false,\\n    \\\"name\\\" : \\\"kBook Pro\\\",\\n    \\\"type\\\" : \\\"Computer\\\",\\n    \\\"volume_percent\\\" : 64\\n  }, {\\n    \\\"id\\\" : \\\"aaea1a3c3778e6d17b90170c5ccb4e2988e847e7\\\",\\n    \\\"is_active\\\" : true,\\n    \\\"is_private_session\\\" : false,\\n    \\\"is_restricted\\\" : false,\\n    \\\"name\\\" : \\\"Theater + Kitchen + Bathroom + Livi + Living Room\\\",\\n    \\\"type\\\" : \\\"Unknown\\\",\\n    \\\"volume_percent\\\" : 25\\n  }, {\\n    \\\"id\\\" : \\\"bc185b9d6dce9dca3994523d627c3597da3038dc\\\",\\n    \\\"is_active\\\" : false,\\n    \\\"is_private_session\\\" : false,\\n    \\\"is_restricted\\\" : false,\\n    \\\"name\\\" : \\\"kofBook\\\",\\n    \\\"type\\\" : \\\"Computer\\\",\\n    \\\"volume_percent\\\" : 67\\n  }, {\\n    \\\"id\\\" : \\\"bdc21246944b2854b6026e541ef7df46cee4db08\\\",\\n    \\\"is_active\\\" : false,\\n    \\\"is_private_session\\\" : false,\\n    \\\"is_restricted\\\" : false,\\n    \\\"name\\\" : \\\"Living Room\\\",\\n    \\\"type\\\" : \\\"Unknown\\\",\\n    \\\"volume_percent\\\" : 20\\n  } ]\\n}\"" }

The response of curl -X "GET" "https://api.spotify.com/v1/me/player/devices" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer ***" is:

{
  "devices": [
    {
      "id": "1b6e8429877f28aeb2f0af52567e9b9224319d3a",
      "is_active": false,
      "is_private_session": false,
      "is_restricted": false,
      "name": "kBook Pro",
      "type": "Computer",
      "volume_percent": 64
    },
    {
      "id": "aaea1a3c3778e6d17b90170c5ccb4e2988e847e7",
      "is_active": true,
      "is_private_session": false,
      "is_restricted": false,
      "name": "Theater + Kitchen + Bathroom + Livi + Living Room",
      "type": "Unknown",
      "volume_percent": 25
    },
    {
      "id": "bc185b9d6dce9dca3994523d627c3597da3038dc",
      "is_active": false,
      "is_private_session": false,
      "is_restricted": false,
      "name": "kofBook",
      "type": "Computer",
      "volume_percent": 67
    },
    {
      "id": "bdc21246944b2854b6026e541ef7df46cee4db08",
      "is_active": false,
      "is_private_session": false,
      "is_restricted": false,
      "name": "Living Room",
      "type": "Unknown",
      "volume_percent": 20
    }
  ]
}

Any idea what went wrong here?

Originally created by @kjedamzik on GitHub (Oct 6, 2018). Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/20 I get an error when I try to: ``` let devices = spotify.device(); println!("{:?}", devices); ``` ``` ErrorMessage { msg: "convert result failed, content \"{\\n \\\"devices\\\" : [ {\\n \\\"id\\\" : \\\"1b6e8429877f28aeb2f0af52567e9b9224319d3a\\\",\\n \\\"is_active\\\" : false,\\n \\\"is_private_session\\\" : false,\\n \\\"is_restricted\\\" : false,\\n \\\"name\\\" : \\\"kBook Pro\\\",\\n \\\"type\\\" : \\\"Computer\\\",\\n \\\"volume_percent\\\" : 64\\n }, {\\n \\\"id\\\" : \\\"aaea1a3c3778e6d17b90170c5ccb4e2988e847e7\\\",\\n \\\"is_active\\\" : true,\\n \\\"is_private_session\\\" : false,\\n \\\"is_restricted\\\" : false,\\n \\\"name\\\" : \\\"Theater + Kitchen + Bathroom + Livi + Living Room\\\",\\n \\\"type\\\" : \\\"Unknown\\\",\\n \\\"volume_percent\\\" : 25\\n }, {\\n \\\"id\\\" : \\\"bc185b9d6dce9dca3994523d627c3597da3038dc\\\",\\n \\\"is_active\\\" : false,\\n \\\"is_private_session\\\" : false,\\n \\\"is_restricted\\\" : false,\\n \\\"name\\\" : \\\"kofBook\\\",\\n \\\"type\\\" : \\\"Computer\\\",\\n \\\"volume_percent\\\" : 67\\n }, {\\n \\\"id\\\" : \\\"bdc21246944b2854b6026e541ef7df46cee4db08\\\",\\n \\\"is_active\\\" : false,\\n \\\"is_private_session\\\" : false,\\n \\\"is_restricted\\\" : false,\\n \\\"name\\\" : \\\"Living Room\\\",\\n \\\"type\\\" : \\\"Unknown\\\",\\n \\\"volume_percent\\\" : 20\\n } ]\\n}\"" } ``` The response of `curl -X "GET" "https://api.spotify.com/v1/me/player/devices" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer ***"` is: ``` { "devices": [ { "id": "1b6e8429877f28aeb2f0af52567e9b9224319d3a", "is_active": false, "is_private_session": false, "is_restricted": false, "name": "kBook Pro", "type": "Computer", "volume_percent": 64 }, { "id": "aaea1a3c3778e6d17b90170c5ccb4e2988e847e7", "is_active": true, "is_private_session": false, "is_restricted": false, "name": "Theater + Kitchen + Bathroom + Livi + Living Room", "type": "Unknown", "volume_percent": 25 }, { "id": "bc185b9d6dce9dca3994523d627c3597da3038dc", "is_active": false, "is_private_session": false, "is_restricted": false, "name": "kofBook", "type": "Computer", "volume_percent": 67 }, { "id": "bdc21246944b2854b6026e541ef7df46cee4db08", "is_active": false, "is_private_session": false, "is_restricted": false, "name": "Living Room", "type": "Unknown", "volume_percent": 20 } ] } ``` Any idea what went wrong here?
kerem 2026-02-27 20:22:34 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@ramsayleung commented on GitHub (Oct 7, 2018):

It seems there is no such Unknown type for DeviceType , you would see github.com/samrayleung/rspotify@b0f82028c2/src/spotify/senum.rs (L1218)

I am trying to fix this mistake

<!-- gh-comment-id:427617806 --> @ramsayleung commented on GitHub (Oct 7, 2018): It seems there is no such `Unknown` type for `DeviceType` , you would see https://github.com/samrayleung/rspotify/blob/b0f82028c29a570fdb943096112617242887e215/src/spotify/senum.rs#L1218 I am trying to fix this mistake
Author
Owner

@ramsayleung commented on GitHub (Oct 7, 2018):

Could you help me test this issue by change dependency to

rspotify = { git = "https://github.com/samrayleung/rspotify", branch = "feature-fix-devices" }

By now there is no decent mocking framework for Rust, I could not test this device function with mocked parameter. And then I have no such spotify devices, so I need you to help me fix this problem.

<!-- gh-comment-id:427622838 --> @ramsayleung commented on GitHub (Oct 7, 2018): Could you help me test this issue by change dependency to ```toml rspotify = { git = "https://github.com/samrayleung/rspotify", branch = "feature-fix-devices" } ``` By now there is no decent mocking framework for Rust, I could not test this `device` function with mocked parameter. And then I have no such `spotify` devices, so I need you to help me fix this problem.
Author
Owner

@kjedamzik commented on GitHub (Oct 7, 2018):

LGTM 👍🏾
You are awesome! Thank you! Works like a charm!

DevicePayload { devices: [Device { id: "1b6e8429877f28aeb2f0af52567e9b9224319d3a", is_active: false, is_restricted: false, name: "kBook Pro", _type: Computer, volume_percent: 64 }, Device { id: "aaea1a3c3778e6d17b90170c5ccb4e2988e847e7", is_active: true, is_restricted: false, name: "Theater + Kitchen + Bathroom + Livi + Living Room + Living Room", _type: Unknown, volume_percent: 30 }, Device { id: "bc185b9d6dce9dca3994523d627c3597da3038dc", is_active: false, is_restricted: false, name: "kofBook", _type: Computer, volume_percent: 67 }] }
<!-- gh-comment-id:427631920 --> @kjedamzik commented on GitHub (Oct 7, 2018): LGTM 👍🏾 You are awesome! Thank you! Works like a charm! ``` DevicePayload { devices: [Device { id: "1b6e8429877f28aeb2f0af52567e9b9224319d3a", is_active: false, is_restricted: false, name: "kBook Pro", _type: Computer, volume_percent: 64 }, Device { id: "aaea1a3c3778e6d17b90170c5ccb4e2988e847e7", is_active: true, is_restricted: false, name: "Theater + Kitchen + Bathroom + Livi + Living Room + Living Room", _type: Unknown, volume_percent: 30 }, Device { id: "bc185b9d6dce9dca3994523d627c3597da3038dc", is_active: false, is_restricted: false, name: "kofBook", _type: Computer, volume_percent: 67 }] } ```
Author
Owner

@ramsayleung commented on GitHub (Oct 7, 2018):

You could change the branch to master

rspotify = { git = "https://github.com/samrayleung/rspotify", branch = "master" }

and then waiting for a tag release. If you don't another question, I am going to close this issue

<!-- gh-comment-id:427636369 --> @ramsayleung commented on GitHub (Oct 7, 2018): You could change the branch to `master` ``` rspotify = { git = "https://github.com/samrayleung/rspotify", branch = "master" } ``` and then waiting for a tag release. If you don't another question, I am going to close this issue
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/rspotify#9
No description provided.