Handle duplicate key and language pairs when updating translations

オープン
#274 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java, spring-boot, sql
領域
backend, database

調査の方向性

Start with updateByi18nId in template/springboot/src/main/java/com/TinyPro/service/imp/II18ServiceImpl.java and compare it with the create flow, which already throws exception.i18.exists. Check I18Repository.java for a lookup by key and language, then confirm the uk_i18_lang_key constraint in I18.java. Done means a conflicting update returns HTTP 400 with exception.i18.exists, a self-update or unused key still saves, and regression tests cover both.

索引モデルが issue の本文から書いたものです。

説明

Summary

Follow up on the review finding in PR #265: updating a translation to a key and language pair used by another translation should return a controlled validation error rather than an internal server error.

Requested by @msslulu. The requester chose to leave the existing logic unchanged in PR #265 and agreed to track this work in a separate issue.

Required changes

  • Verify the current updateByi18nId behavior in template/springboot/src/main/java/com/TinyPro/service/imp/II18ServiceImpl.java.
  • Before saving an update, check whether another translation has the requested key and language. Exclude the translation being updated.
  • If a conflict exists, throw exception.i18.exists with HttpStatus.BAD_REQUEST, matching the create flow.
  • Keep the uk_i18_lang_key unique constraint and preserve the save flow for non-conflicting updates.
  • Add regression coverage for conflicting and non-conflicting updates.

Rationale

The review reported that duplicate updates fail at transaction commit with HTTP 500, while the create flow returns HTTP 400 with exception.i18.exists. Consistent conflict handling gives API clients an actionable error.

Affected areas

  • template/springboot/src/main/java/com/TinyPro/service/imp/II18ServiceImpl.java
  • template/springboot/src/main/java/com/TinyPro/jpa/I18Repository.java
  • template/springboot/src/main/java/com/TinyPro/entity/po/I18.java
  • Translation service/controller tests as appropriate.

Acceptance criteria

  • Updating a translation to another translation's key and language returns HTTP 400 with exception.i18.exists.
  • Updating a translation without changing its own key and language does not produce a false conflict.
  • Updating to an unused key and language succeeds.
  • A rejected update does not change the stored translation.
  • The database unique constraint remains in place.
  • Regression tests cover these cases.

References

主要言語
TypeScript
スター
88
フォーク
29
平均マージ
1日 2時間
マージ済み PR(30日)
42

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

opentiny/tiny-pro のほかの issue

opentiny/tiny-pro の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。