Skip to content

fix(chart): PerUserDriveChart.update で userId が null のシステム所有ファイルをスキップ#17499

Open
sasagar wants to merge 1 commit into
misskey-dev:developfrom
ikaskey:fix/per-user-drive-chart-null-group
Open

fix(chart): PerUserDriveChart.update で userId が null のシステム所有ファイルをスキップ#17499
sasagar wants to merge 1 commit into
misskey-dev:developfrom
ikaskey:fix/per-user-drive-chart-null-group

Conversation

@sasagar
Copy link
Copy Markdown
Contributor

@sasagar sasagar commented May 26, 2026

Fixes #17498

概要

PerUserDriveChart.update(file, isAdditional)Chart.commit()group 引数として file.userId をそのまま渡しているため、MiDriveFile.userIdnull のファイル(インスタンスアイコン/バナー、admin エンドポイント経由のカスタム絵文字画像アップロード、フェッチされたシステムアバター等のシステム所有ファイル)に対する更新で、__chart__per_user_drive.groupvarchar(128) NOT NULL 制約違反となり ChartManagementService の保存タイマーから例外が出ていました。

変更内容

  • update() の冒頭で file.userId == null の場合は早期 return(no-op)。
  • 所有者の無いファイルに対する「ユーザーごとの」ドライブ集計は定義できないため、行を作らないのが妥当という判断です。

CHANGELOG.md

Unreleased > Server に追記しています。

動作確認

  • 修正前: __chart__per_user_drive への INSERT 時に null value in column "group" で例外。
  • 修正後: file.userId == null の入力は事前にスキップされ、commit() 自体が呼ばれない(他ユーザー所有ファイルの集計は従来通り)。

影響

  • 既存のユーザー所有ファイルに対する chart 動作は不変。
  • システム所有ファイルは元々ユーザーに紐付かないので per-user 集計の対象外として扱う、というのが直感的・破壊的でない選択肢です。

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 26, 2026
@github-actions github-actions Bot added the packages/backend Server side specific issue/PR label May 26, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 24.99%. Comparing base (1cd6c9e) to head (758130b).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #17499      +/-   ##
===========================================
+ Coverage    15.27%   24.99%   +9.71%     
===========================================
  Files          247     1158     +911     
  Lines        12338    39431   +27093     
  Branches      4178    10973    +6795     
===========================================
+ Hits          1885     9854    +7969     
- Misses        8188    23700   +15512     
- Partials      2265     5877    +3612     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

このPRによるapi.jsonの差分
差分はありません。
Get diff files from Workflow Page

@github-actions
Copy link
Copy Markdown
Contributor

Backend memory usage comparison

Before GC

Metric base (MB) head (MB) Diff (MB) Diff (%)
VmRSS 306.06 MB 306.27 MB +0.21 MB +0.06%
VmHWM 306.06 MB 306.27 MB +0.21 MB +0.06%
VmSize 23171.54 MB 23171.78 MB 0.23 MB 0%
VmData 1371.14 MB 1371.57 MB +0.42 MB +0.03%

After GC

Metric base (MB) head (MB) Diff (MB) Diff (%)
VmRSS 306.12 MB 306.45 MB +0.33 MB +0.10%
VmHWM 306.12 MB 306.45 MB +0.33 MB +0.10%
VmSize 23171.63 MB 23172.20 MB 0.56 MB 0%
VmData 1371.22 MB 1371.98 MB +0.76 MB +0.05%

After Request

Metric base (MB) head (MB) Diff (MB) Diff (%)
VmRSS 306.51 MB 306.92 MB +0.40 MB +0.13%
VmHWM 306.51 MB 306.92 MB +0.40 MB +0.13%
VmSize 23171.63 MB 23172.28 MB 0.65 MB 0%
VmData 1371.30 MB 1372.15 MB +0.84 MB +0.06%

See workflow logs for details

@kakkokari-gtyih kakkokari-gtyih requested a review from syuilo May 26, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages/backend Server side specific issue/PR size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

1 participant