mirror of
https://github.com/ramsayleung/rspotify.git
synced 2026-04-25 23:45:52 +03:00
[GH-ISSUE #363] Progress time received from API can be negative #113
Labels
No labels
Stale
bug
discussion
enhancement
good first issue
good first issue
help wanted
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/rspotify#113
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @bamode on GitHub (Oct 15, 2022).
Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/363
Describe the bug
This issue effects specifically the structs
CurrentlyPlayingContextandCurrentPlaybackContextwhen deserializing the Spotify API response that corresponds to theprogressfield of these structs. It appears to be parsing it as au32to turn into astd::time::Durationand this part of the API response is occasionally a negative number. This results in upstream bugs in the spotifyd and spotify-tui projects.Expected behavior
The API deserialization should be able to replace an unexpected negative time value with some default.
@ramsayleung commented on GitHub (Oct 15, 2022):
Thanks for your report, The Spotify's documentation doesn't point out the
progresscould be a negative number.If
progresscould be a negative number, then parsing it as anu32to turn into astd::time::Durationis inappropriate.std::time::Durationdoesn't support negative value.I would like to replace
std::time::Durationtochrono::Duration, which supports negative value. It would be a break change.@ramsayleung commented on GitHub (Oct 19, 2022):
If we consider replacing
std::time::Durationtochrono::Duration, we need to replace all fields usingstd::time::Durationtochrono::Duration. Otherwise, it will become inconsistent that some fields are usingstd::time::Durationto represent time, other fields are usingchrono::Durationto represent time.@marioortizmanero commented on GitHub (Dec 26, 2022):
Do we know in which cases we receive a negative value? Another option is to have a custom serializer that sets these cases to zero, though I do prefer to represent the API as closely as possible with
chrono::Duration.@ramsayleung commented on GitHub (Dec 27, 2022):
As @bamode points out, the
progressfield inCurrentlyPlayingContextcould be negative. I think it doesn't make sense if we set these cases to zero.@github-actions[bot] commented on GitHub (Jun 24, 2023):
Message to comment on stale issues. If none provided, will not mark issues stale