#364606: Test for Composer package data sorting behaviour
What does this MR do and why?
Add a failing test to establish current Composer package data sorting behaviour.
Refs #364606. The goal of this MR is to demonstrate the incorrect behaviour via a test; once there's agreement this is incorrect, we can consider approaches to addressing the behaviour.
Sorting package metadata can trigger unexpected results for tools consuming Gitlab's Packagist repository. Gitlab should ideally not sort package metadata in this way.
I believe the underlying issue is that composer_json is stored in Postgres as jsonb, and PostgreSQL's jsonb type does not preserve object key order - on storage it reorders keys by byte length first, then lexically. Source order is lost when stored and the inputs will only be retrieved in the state Postgres stores them.
Some approaches to address this might be:
- changing the storage type (eg from JSONB to JSON), either by converting existing
composer_jsoncolumn, - storing raw data separately, which feels a bit duplicative
- reading
composer.jsonfrom Git storage and serving that directly, without the Postgres round-trip
This test should demonstrate the current behaviour using the example already provided in issue description.
References
How to set up and validate locally
Refer #364606 for examples provided, hopeful that the test helps. This MR does not (yet) propose a fix.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #364606