Skip to content

fix: Plugin:register_note_post_interruptorを使用するとノートを投稿できない問題を修正 - #18070

Open
jj1guj wants to merge 4 commits into
misskey-dev:developfrom
jj1guj:fix/deepclone-skip-undefined
Open

jj1guj wants to merge 4 commits into
misskey-dev:developfrom
jj1guj:fix/deepclone-skip-undefined

Conversation

@jj1guj

@jj1guj jj1guj commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

What

deepClone(frontend: packages/frontend/src/utility/clone.ts、backend: packages/backend/src/misc/clone.ts)で、値が undefined のプロパティをキーごと複製しないようにしました。

これにより、Plugin:register_note_post_interruptor を使ったプラグインを有効にしてもノートを投稿できるようになります。

Why

Plugin:register_note_post_interruptor を使ったプラグインを有効にすると、プラグインが note を加工せずに返す場合でも、投稿時に Invalid param.(3d81ceae-475f-4600-b2a8-2bc116157532)になります。
発見の経緯と調査内容は jj1guj#214 にまとめています。

原因は次のとおりです。

  1. MkPostForm の postData は、使わない項目(fileIds、visibleUserIds など)を値が undefined のキーとして持っている。deepClone はこのキーを残したまま複製し、プラグインに渡す
  2. AiScript の jsToVal は Object.entries でキーを列挙し、undefined を NULL に変換する
  3. スクリプトの戻り値を valToJs で JS の値に戻すと fileIds: null などが残り、そのまま notes/create に送られる。fileIds と visibleUserIds は nullable ではないため、パラメータ検証に失敗する

この問題は #9207 で報告されており、#12926 で deepClone の修正(if (v !== undefined) obj[k] = deepClone(v);)が入りました。しかしレビュー中のコミット 57324bf で obj[k] = v === undefined ? undefined : deepClone(v); に変更されています。deepClone(undefined) は undefined を返すため、変更後の処理は修正前と実質的に同じで、問題が再発していました。
この PR では、#12926 で最初に入った修正と同じ形に戻します。

Additional info (optional)

  • この変更により、deepClone で値が undefined のプロパティは複製後にキーごと存在しなくなります。

Checklist

  • Read the contribution guide
  • Test working in a local environment
  • (If needed) Add story of storybook
  • (If needed) Update CHANGELOG.md
  • (If possible) Add tests

@github-actions github-actions Bot added packages/frontend Client side specific issue/PR packages/backend Server side specific issue/PR labels Oct 29, 2026
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters: 1
  • CHANGELOG.md is excluded by !CHANGELOG.md

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between c05e844 and 6b0c4bc.

Files ignored due to path filters: 1
  • CHANGELOG.md is excluded by !CHANGELOG.md
Files selected for processing: 2
  • packages/backend/src/misc/clone.ts
  • packages/frontend/src/utility/clone.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

バックエンドとフロントエンドのdeepCloneを変更しました。複製元のオブジェクトにあるundefinedのプロパティは複製先に追加されません。その他の値は従来どおり再帰的に複製されます。

Changes: deepCloneのundefinedプロパティ処理

Layer / File(s) Summary
undefinedプロパティの除外
packages/backend/src/misc/clone.ts, packages/frontend/src/utility/clone.ts
両方のdeepCloneで、undefinedのプロパティを複製先に追加しないよう変更しました。その他の値は引き続き再帰的に複製します。

Priority: Pending latest changes

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Suggested reviewers: syuilo

Merge Risk: Minimal · previous review 6b0c4

This targeted change addresses the reported posting failure without an identified merge-blocking risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed タイトルは、Plugin:register_note_post_interruptor 使用時にノートを投稿できない問題の修正を明確に示しており、主な変更内容と一致しています。
Description check Passed 説明にはテンプレートの What、Why、Additional info、Checklist が含まれています。原因、影響、修正内容、確認状況も具体的に記載されています。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

複製の枝に、ひとつの変化
undefinedはそっと通り過ぎ
定義された値は、再帰の道へ
バックエンドにも、フロントエンドにも
同じふるまいが並びます

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 26.74%. Comparing base (c05e844) to head (0f43f1e).

Files with missing lines Patch % Lines
packages/backend/src/misc/clone.ts 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           develop   #18070       +/-   ##
============================================
+ Coverage    12.85%   26.74%   +13.89%     
============================================
  Files          225     1162      +937     
  Lines        11096    39871    +28775     
  Branches      3682    10982     +7300     
============================================
+ Hits          1426    10665     +9239     
- Misses        7595    23432    +15837     
- Partials      2075     5774     +3699     

☔ View full report in Codecov by Harness.
📢 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

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

⚙️ Backend Diagnostics Report

Memory: After GC

(No significant changes)

V8 Heap Snapshot Statistics

Metric @ Base @ Head Δ MAD
$\color{gray}{\rule{8pt}{8pt}}$ Total 86 MB
± 5 KB
86 MB
± 6.2 KB
$\text{+5.9 KB}$
$\text{+0\%}$
8 KB
$\color{orange}{\rule{8pt}{8pt}}$ Code 24 MB 24 MB $\text{+1.9 KB}$ 9.8 KB
$\color{red}{\rule{8pt}{8pt}}$ Strings 30 MB 30 MB $\text{+712 B}$ 2.5 KB
$\color{cyan}{\rule{8pt}{8pt}}$ JS arrays 5.4 MB 5.4 MB 0 B 0 B
$\color{green}{\rule{8pt}{8pt}}$ Typed arrays 610 KB 610 KB 0 B 0 B
$\color{yellow}{\rule{8pt}{8pt}}$ System objects 2.1 MB 2.1 MB $\text{-2 KB}$ 309 B
$\color{violet}{\rule{8pt}{8pt}}$ Other JS objs 23 MB 23 MB $\text{+136 B}$ 169 B
$\color{pink}{\rule{8pt}{8pt}}$ Other non-JS objs 40 KB 40 KB 0 B 0 B

Download representative heap snapshot: base / head

@github-actions

Copy link
Copy Markdown
Contributor

🖥 Frontend Diagnostics Report

(No significant changes)

View details

Requests by resource type
Type Requests Encoded bytes
Base Head Δ Base Head Δ
Document 2 2 0 33 KB 33 KB 0 B
Script 148 148 0 2.1 MB 2.1 MB $\color{green}{\text{-8 B}}$
Stylesheet 58 58 0 284 KB 284 KB 0 B
Fetch 20 20 0 46 KB 46 KB 0 B
Image 10 10 0 254 KB 254 KB 0 B
Font 2 2 0 118 KB 118 KB 0 B
Other 9 9 0 421 KB 421 KB $\color{orange}{\text{+70 B}}$
V8 heap snapshot statistics
Metric @ Base @ Head Δ MAD
$\color{gray}{\rule{8pt}{8pt}}$ Total 11 MB
± 7.1 KB
11 MB
± 11 KB
$\text{-24 KB}$
$\text{-0.2\%}$
13 KB
$\color{orange}{\rule{8pt}{8pt}}$ Code 2.8 MB 2.8 MB $\text{-17 KB}$ 542 B
$\color{red}{\rule{8pt}{8pt}}$ Strings 1.3 MB 1.3 MB $\text{-532 B}$ 273 B
$\color{cyan}{\rule{8pt}{8pt}}$ JS arrays 112 KB 112 KB 0 B 92 B
$\color{green}{\rule{8pt}{8pt}}$ Typed arrays 0 B 0 B 0 B 0 B
$\color{yellow}{\rule{8pt}{8pt}}$ System objects 0 B 0 B 0 B 0 B
$\color{violet}{\rule{8pt}{8pt}}$ Other JS objs 2 MB 2 MB $\text{-1.4 KB}$ 144 B
$\color{pink}{\rule{8pt}{8pt}}$ Other non-JS objs 5 MB 5 MB $\text{-10 KB}$ 12 KB

Download representative heap snapshot: base / head

📦 Bundle Stats

Chunk size diff (0 updated, 0 added, 0 removed)
Chunk Base Head Δ Δ (%)
(total) 6 MB 6 MB $\text{-4 B}$ $\text{-0\%}$
(other generated chunks) 2 MB 2 MB $\text{-4 B}$ $\text{-0\%}$
Startup chunk size (0 updated, 0 added, 0 removed)
Chunk Base Head Δ Δ (%)
(total) 1 MB 1 MB $\text{-4 B}$ $\text{-0\%}$
(other generated chunks) 759 KB 759 KB $\text{-4 B}$ $\text{-0\%}$
(other) 284 KB 284 KB 0 B 0%

Startup chunks are the Vite entry for src/_boot_.ts and its static imports.

Bundles Modules Entries Imports Size
Static Dynamic Rendered Gzip Brotli
Base 469 2,857 21 10,348 333 10 MB 2.8 MB 2.4 MB
Head 469 2,857 21 10,348 333 10 MB 2.8 MB 2.4 MB
Δ 0 0 0 0 0 $\text{-6 B}$ $\text{-15 B}$ $\text{-44 B}$
Δ (%) 0% 0% 0% 0% 0% $\text{-0\%}$ $\text{-0\%}$ $\text{-0\%}$

Open treemap HTML

@syuilo

syuilo commented Oct 29, 2026

Copy link
Copy Markdown
Member

ありがとうございます。応急処置としては良さそうですが、そもそもAiScriptがundefinedをnullに変換することが正しいのか疑問があるので、根本的にはそれが直った方が良さそうですね

@jj1guj

jj1guj commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

そもそもAiScriptがundefinedをnullに変換することが正しいのか疑問があるので、根本的にはそれが直った方が良さそうですね

私も同じ見解でいます。
しかし2024年にこれと同じ趣旨のissueが立てられており、このときはあくまでMisskey側のバグだから修正する予定はないとしてNot plannedでcloseされています。
そのため、AiScript側での修正は望み薄だと考えているのですが実際のところどうでしょうか?
aiscript-dev/aiscript#607

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 packages/frontend Client side specific issue/PR

Projects

Development

Successfully merging this pull request may close these issues.

2 participants