Skip to content

fix(metadata): order series positions with an invariant parse - #892

Open
m4bard wants to merge 2 commits into
Listenarrs:canaryfrom
m4bard:fix/795-series-order-culture
Open

fix(metadata): order series positions with an invariant parse#892
m4bard wants to merge 2 commits into
Listenarrs:canaryfrom
m4bard:fix/795-series-order-culture

Conversation

@m4bard

@m4bard m4bard commented Aug 24, 2026

Copy link
Copy Markdown

Fixes #795.

A series position arrives from Audible's sequence/sort field as a string that always uses . as the decimal separator. ParseSeriesPosition parsed it with the ambient culture, so on a server whose culture treats . as the group separator the value was read as a different number.

de-DE   "1.5" parses as 15          novella sorts after book 10
fr-FR   "1.5" does not parse at all  falls to decimal.MaxValue, sorts last

A default container runs under the invariant culture and was never affected, which is why this is easy to miss. It shows up once the process has a real culture, which happens when LANG or LC_ALL is set and on a desktop install that inherits the operating system's locale.

The parse is now pinned to CultureInfo.InvariantCulture with NumberStyles.Number. Sort data, parsed the same way everywhere.

The tiebreak question from the issue, deliberately not answered here

I asked on the issue what should happen to a position that is not a decimal at all, the 1-4 of an omnibus. This PR does not change that: those still sort last, exactly as they do today.

That is not me deciding the question. It is me keeping this change to the part that is unambiguously a bug, so the ordering of omnibus entries stays whatever you decide it should be, separately. If you would rather they sorted first, or kept their catalogue order, that is a different change and I am happy to write it once you say which.

Tests

SeriesPositionOrderingTests, thirteen cases. The parse is asserted directly under de-DE, fr-FR and the invariant culture, and the ordering is asserted end to end over a mixed series.

Control, with only the parse reverted to the culture-dependent form and everything else left in place:

Expected: 1,5                       Actual: 15
Expected: 1,5                       Actual: 79228162514264337593543950335
Expected: ["1", "1.5", "2", "10", "1-4"]
Actual:   ["1", "2", "10", "1.5", "1-4"]

That last line is the reported symptom: the novella lands after book 10.

ParseSeriesPosition goes from private to internal so the culture behaviour can be asserted on the method rather than inferred from the ordering. That accessibility change is why a plain revert of the whole commit will not compile; the control above reverts only the parse.

Full suite 3051 passed, 0 failed, 127 skipped, on canary d25b3e11 (1.3.3).

One housekeeping commit alongside: this branch predated TestClasses_FollowRepositoryConventions, so the test class needed BaseTests and its traits to satisfy the architecture suite.

m4bard added 2 commits August 24, 2026 14:27
An Audible series position arrives as a string that always uses '.' as the
decimal separator, so parsing it under the server's culture makes the order
depend on the host locale. Where '.' is the group separator a position of
"1.5" read as 15 and the novella sorted after book 10; where ',' is the
decimal separator it did not parse at all and fell to decimal.MaxValue.

A stock container runs under the invariant culture and was unaffected. The
bug needed a real culture to reach the process, which happens when LANG or
LC_ALL is set and on a desktop install that inherits the OS locale.

Non-numeric positions such as an omnibus at "1-4" still sort last, which is
unchanged and deliberate.

ParseSeriesPosition becomes internal so the culture behaviour can be
asserted against the real method rather than a copy of it.

Fixes Listenarrs#795
…#717 added

This branch predated TestClasses_FollowRepositoryConventions, so the test class
inherited nothing and carried neither trait. Inherit BaseTests and add the exact
Name trait and a Category, which is what the architecture suite now requires.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Series order depends on the server's locale: a position of "1.5" sorts after book 10

1 participant