[PR #531] [MERGED] [feat] Add fallback variant to capture unknown variant #515

Closed
opened 2026-02-27 20:25:01 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ramsayleung/rspotify/pull/531
Author: @ramsayleung
Created: 7/7/2025
Status: Merged
Merged: 7/7/2025
Merged by: @ramsayleung

Base: masterHead: ramsay/allow-enum-unknown-variant


📝 Commits (6)

  • af30dd9 [feat]Add fallback variant to capture unknown variant
  • bfbeabb Add unit test for fallback variant
  • afa3623 Fix cargo fmt error
  • 3e21d84 Fix cargo clippy error
  • 8a6475f Fix clippy error again
  • 39aa84e Fix cargo clippy error

📊 Changes

6 files changed (+26 additions, -6 deletions)

View changed files

📝 examples/webapp/src/main.rs (+1 -1)
📝 rspotify-http/src/reqwest.rs (+1 -1)
📝 rspotify-http/src/ureq.rs (+1 -1)
📝 rspotify-model/src/custom_serde.rs (+1 -2)
📝 rspotify-model/src/enums/types.rs (+5 -1)
📝 tests/test_models.rs (+17 -0)

📄 Description

To prevent RSpotify from raising a deserialization error whenever Spotify adds new variant type

Description

Whenever Spotify introduces a new type, this library will fail to deserialize the JSON, as it couldn't find the matched variant for the newly added type.

Add a fallback variant to capture this new type to prevent us from raising JSON parse error

Motivation and Context

#525

Dependencies

None

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

  • test_fallback_variant_type_to_capture_new_type: passed

Is this change properly documented?

It's unnecessary


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ramsayleung/rspotify/pull/531 **Author:** [@ramsayleung](https://github.com/ramsayleung) **Created:** 7/7/2025 **Status:** ✅ Merged **Merged:** 7/7/2025 **Merged by:** [@ramsayleung](https://github.com/ramsayleung) **Base:** `master` ← **Head:** `ramsay/allow-enum-unknown-variant` --- ### 📝 Commits (6) - [`af30dd9`](https://github.com/ramsayleung/rspotify/commit/af30dd9b82a4b1db73587fe40e221071b83ea204) [feat]Add fallback variant to capture unknown variant - [`bfbeabb`](https://github.com/ramsayleung/rspotify/commit/bfbeabb2f3efad0f904ce59bc0de6d459c29b9c8) Add unit test for fallback variant - [`afa3623`](https://github.com/ramsayleung/rspotify/commit/afa36232807f0d9c76ba38b86493d58ae4f6b38c) Fix cargo fmt error - [`3e21d84`](https://github.com/ramsayleung/rspotify/commit/3e21d84beb7f7668d517b2dd56bd4bb9320a44f4) Fix cargo clippy error - [`8a6475f`](https://github.com/ramsayleung/rspotify/commit/8a6475f74850a1e0df2e7a24464cacc2cbe78775) Fix clippy error again - [`39aa84e`](https://github.com/ramsayleung/rspotify/commit/39aa84ea1b4853be11c73e881108d51215238f7e) Fix cargo clippy error ### 📊 Changes **6 files changed** (+26 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `examples/webapp/src/main.rs` (+1 -1) 📝 `rspotify-http/src/reqwest.rs` (+1 -1) 📝 `rspotify-http/src/ureq.rs` (+1 -1) 📝 `rspotify-model/src/custom_serde.rs` (+1 -2) 📝 `rspotify-model/src/enums/types.rs` (+5 -1) 📝 `tests/test_models.rs` (+17 -0) </details> ### 📄 Description To prevent `RSpotify` from raising a deserialization error whenever Spotify adds new variant type ## Description Whenever Spotify introduces a new type, this library will fail to deserialize the JSON, as it couldn't find the matched variant for the newly added type. Add a fallback variant to capture this new type to prevent us from raising JSON parse error ## Motivation and Context #525 ## Dependencies None ## Type of change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ## How has this been tested? - [ ] `test_fallback_variant_type_to_capture_new_type`: passed ## Is this change properly documented? It's unnecessary --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:25:01 +03:00
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#515
No description provided.