[GRDM-57850] Fix encoding error for Japanese Characters in IdP Authentication Attributes#742
Draft
ndnhat1 wants to merge 5 commits into
Draft
Conversation
…i_grdm_202603_step9/2.1_idp_auth_response_text_display
yacchin1205
requested changes
Jun 19, 2026
yacchin1205
left a comment
There was a problem hiding this comment.
views.pyおよびテストは問題ないように思います。 fix_encoding_errors.py について、以下の2種類の課題があると思いますので、ご検討ください。
- エンコーディング検出の問題:
HTTP_AUTH_DISPLAYNAMEの補正は Shibboleth/WSGI ヘッダ由来という入力経路が明確なので妥当だと思います。一方で、このスクリプトは DB 内の任意文字列(OSFUser.fullname, given_name, jobs, schools, social, UserExtendedData.data などを横断... Shibboleth直接?由来以外のものを含む)を対象に、文字列の見た目から「UTF-8 bytes が Latin-1 として保存された値」かどうかを推定して修復しようとしています。一般論として、この判定を安全に自動化する手段はないと思います(多分にheuristic)。特に errors='replace' による partial result を --include-unrecoverable で DB に書き戻せる設計は、データ破損リスクがあります。まずは候補 CSV の出力に留め、DB 更新は人手確認済みのoriginal_value / suggested_value を明示入力する二段階方式にする方が安全だと思います。 - エラー処理の問題: DB 修復スクリプトとしては、想定外の状態を 'N/A' や空 dict/list にフォールバックして処理継続している点が気になります。例えば user._id は修復結果の追跡キーなので、欠損時に 'N/A' として CSV に流すと監査・再照合が難しくなります。また record.user 不在、OSFUser/UserExtendedData.DoesNotExist、getattr(..., None)、except Exception での握り潰しなどは、不変条件違反や実装ミスを隠してしまいます。修復対象データの追跡性を保つためにも、想定外の状態では fail fast するか、事前検証で明示的に除外する方がよいと思います。
|
ご指摘ありがとうございます。Migration Script を以下の方針で見直します。 まとめ
1. partial 結果の DB 書き戻し廃止
2. エラー処理の Fail Fast 化ご指摘の「フォールバック値による処理継続」「例外握り潰し」を廃止し、データ不備や想定外の状態を検知した時点で例外をスローして即時停止する設計に変更いたします。 具体的な変更内容:
3. CSV ファイル経由の二段階反映ご提案の「DB 更新は人手確認済みの 運用フロー
CSV インポート時のバリデーション以下のバリデーションを実施し、エラー検知時は即時停止(処理全体をロールバック)します。
整合性チェックで不一致を検知した場合エクスポート以降に対象データが他の操作(ユーザのログインや Web 画面からの編集等)で更新された可能性があるため、処理を停止します。最新の状態で CSV を再エクスポートいただいた上で再実行する運用となります。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Resolve encoding error in displaying authentication information received from IdP
Changes
Fixed the handling of character encoding for IdP attributes to properly display Japanese characters.
QA Notes
Documentation
Side Effects
Ticket
57850