/
/
/
# What does this implement/fix? When several parts of the server ask for the same item at the same time, we collapse those into a single request. Which requests count as "the same" is decided by a key built from the call arguments, and that key was built by stringifying every argument. For the seven places that pass a whole media item as a `fallback`, that meant the key contained the item's full representation — around 2000 characters — and because some of its fields are sets, two equal items could produce two different keys. Identical requests then missed each other and ran twice. The key was also built by joining the parts with a dot, while item ids can contain dots themselves, so different calls could in theory produce the same key. No user-visible bug here — the worst case was a duplicate request — so this is maintenance. - Key each call on its parameter names, so the same call keys the same whether arguments are passed positionally or by keyword - Key a media item argument on its uri instead of its full representation (~2000 -> ~190 characters, and stable for equal items) - Encode the key so parts containing punctuation can no longer run together - Keep a full item and a short reference to that same item apart, as they resolve differently - Tests for the above, including that a forced refresh still never joins a normal request ## Types of changes - [ ] Bugfix (non-breaking change which fixes an issue) — `bugfix` - [ ] New feature (non-breaking change which adds functionality) — `new-feature` - [ ] Enhancement to an existing feature — `enhancement` - [ ] New music/player/metadata/plugin provider — `new-provider` - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) — `breaking-change` - [ ] Refactor (no behaviour change) — `refactor` - [ ] Documentation only — `documentation` - [x] Maintenance / chore — `maintenance` - [ ] CI / workflow change — `ci` - [ ] Dependencies bump — `dependencies` ## Checklist - [x] The code change is tested and works locally. - [x] `pre-commit run --all-files` passes. - [x] `pytest` passes, and tests have been added/updated under `tests/` where applicable. - [ ] For changes to shared models, the companion PR in `music-assistant/models` is linked. - [ ] For changes affecting the UI, the companion PR in `music-assistant/frontend` is linked. - [x] I have read and complied with the project's [AI Policy](https://github.com/music-assistant/.github/blob/main/AI_POLICY.md) for any AI-assisted contributions. - [ ] I have raised a PR against the documentation repository targeting the main or beta branch as appropriate.