Skip to content

fix(discovery): format duplicate similarity with Locale.ROOT (robust duplicate %) - #79

Merged
jhosepmyr merged 1 commit into
developfrom
bugfix/duplicate-similarity-locale
Jul 10, 2026
Merged

fix(discovery): format duplicate similarity with Locale.ROOT (robust duplicate %)#79
jhosepmyr merged 1 commit into
developfrom
bugfix/duplicate-similarity-locale

Conversation

@jhosepmyr

Copy link
Copy Markdown
Contributor

Description

The near-duplicate 409 DUPLICATE_USER_STORY carries the similarity as a machine-parsed value: the frontend regexes similarity 0.87 out of the ProblemDetail detail and shows it as a percentage on the manual-create and import duplicate surfaces. It was built with "...%.2f".formatted(similarity), which uses the JVM default locale — a comma-decimal locale (es-PE, Germany, …) would emit 0,87, and the client regex ([0-9]*\.?[0-9]+) would then read the score as 0 (0%).

Force Locale.ROOT so the decimal separator is always a dot, regardless of the container locale. Found during the discovery streaming audit — the duplicate flow is part of the demo.

Bounded context / area: discovery

Type of Change

  • fix
  • test

Checklist

  • Targets develop
  • Conventional Commits
  • ./gradlew compile + new unit test pass (locale-pinned assertion)
  • No secrets committed
  • CHANGELOG — omitted (tiny robustness fix)

How to Test

New DiscoveryExceptionsTest pins the default locale to Locale.GERMANY and asserts the message contains similarity 0.87 (dot), not 0,87. Manually: create a near-duplicate story → the 409 toast shows the correct similarity % in any locale.

The near-duplicate 409's ProblemDetail detail carries the similarity as a
machine-parsed value (the client regexes "similarity 0.87" and shows the %).
It was formatted with the JVM default locale, so a comma-decimal locale would
emit "0,87" and the client would read the score as 0 (0%) on the duplicate
surface. Force Locale.ROOT so the decimal is always a dot.
@jhosepmyr
jhosepmyr requested a review from Eric396 as a code owner July 10, 2026 18:41
@jhosepmyr
jhosepmyr merged commit 95a106c into develop Jul 10, 2026
5 checks passed
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.

1 participant