Skip to content

Release: staging -> main (2026-04-14)#498

Merged
is0692vs merged 3 commits into
mainfrom
staging
Apr 15, 2026
Merged

Release: staging -> main (2026-04-14)#498
is0692vs merged 3 commits into
mainfrom
staging

Conversation

@github-actions

@github-actions github-actions Bot commented Apr 14, 2026

Copy link
Copy Markdown

Summary

Promotes staging into main.

  • Source branch: staging
  • Target branch: main
  • Generated by npm run pr:promote

Included PRs

Compare

Greptile Summary

CodSpeed のパフォーマンス回帰を修正するため、validateMagicNumbers 内のマジックナンバー検出ループを、各シグネチャに対応するインライン if-else ブランチに展開しています。バイト比較のロジックは元の実装と完全に等価であり、機能的な問題は見当たりません。

Confidence Score: 5/5

  • このPRはマージしても安全です。変更は機能的に等価なパフォーマンス最適化です。
  • 全ての指摘事項はP2(スタイル・保守性)レベルであり、バグや機能的な問題は存在しません。バイト比較ロジックはMAGIC_NUMBER_MAPの元の実装と完全に一致しており、正確性に問題はありません。
  • 特に注意が必要なファイルはありません。

Important Files Changed

Filename Overview
apps/api/src/utils/file.ts マジックナンバー検出のループをインライン if-else に展開してパフォーマンスを改善。論理的には元のコードと等価だが、MAGIC_NUMBER_MAP が部分的にしか使われなくなる保守性の懸念が残る。

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[validateMagicNumbers] --> B[Read first MAX_MAGIC_SIZE bytes]
    B --> C{PDF signature match?}
    C -- Yes --> D[detectedType = pdf]
    C -- No --> E{PNG signature match?}
    E -- Yes --> F[detectedType = png]
    E -- No --> G{JPEG signature match?}
    G -- Yes --> H[detectedType = jpeg]
    G -- No --> I{OLE signature match?}
    I -- Yes --> J[detectedType = ole-storage]
    I -- No --> K{ZIP signature match?}
    K -- Yes --> L[detectedType = zip]
    K -- No --> M[return false]
    D & F & H & J & L --> N{MIME_COMPATIBILITY check}
    N -- mismatch --> O[return false]
    N -- match --> P{PPTX?}
    P -- Yes --> Q[hasZipEntry check]
    P -- No --> R{PPT?}
    R -- Yes --> S[hasOleStream check]
    R -- No --> T[return true]
    Q & S --> T
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: apps/api/src/utils/file.ts
Line: 235-245

Comment:
**`MAGIC_NUMBER_MAP` との乖離リスク**

`MAGIC_NUMBER_MAP` はマジックナンバーの定義を持ち続けていますが、実際の判定ロジックはこの if-else チェーンに移されました。将来の開発者が新しいファイルタイプを追加する際、`MAGIC_NUMBER_MAP` にエントリを追加しても、対応する if-else ブランチを追加しないと **サイレントに検出スキップ**されます(`MAX_MAGIC_SIZE` の計算には使われるが、マッチングには使われないため)。

`MAGIC_NUMBER_MAP` の用途を `MAX_MAGIC_SIZE` のみに限定するか、コメントで両箇所の同期が必要であることを明示することを検討してください。

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "Merge pull request #495 from Hiroki-org/..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

google-labs-jules Bot and others added 2 commits April 14, 2026 10:36
…enchmark regression

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
@github-actions github-actions Bot added automated Automated main-to-staging sync PR release Release promotion PR labels Apr 14, 2026
@vercel

vercel Bot commented Apr 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
open-shelf Ignored Ignored Apr 14, 2026 0:04am

Comment on lines +235 to 245
if (bytes.length >= 5 && bytes[0] === 0x25 && bytes[1] === 0x50 && bytes[2] === 0x44 && bytes[3] === 0x46 && bytes[4] === 0x2d) {
detectedType = "application/pdf";
} else if (bytes.length >= 8 && bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47 && bytes[4] === 0x0d && bytes[5] === 0x0a && bytes[6] === 0x1a && bytes[7] === 0x0a) {
detectedType = "image/png";
} else if (bytes.length >= 3 && bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff) {
detectedType = "image/jpeg";
} else if (bytes.length >= 8 && bytes[0] === 0xd0 && bytes[1] === 0xcf && bytes[2] === 0x11 && bytes[3] === 0xe0 && bytes[4] === 0xa1 && bytes[5] === 0xb1 && bytes[6] === 0x1a && bytes[7] === 0xe1) {
detectedType = "application/x-ole-storage";
} else if (bytes.length >= 4 && bytes[0] === 0x50 && bytes[1] === 0x4b && bytes[2] === 0x03 && bytes[3] === 0x04) {
detectedType = "application/zip";
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 MAGIC_NUMBER_MAP との乖離リスク

MAGIC_NUMBER_MAP はマジックナンバーの定義を持ち続けていますが、実際の判定ロジックはこの if-else チェーンに移されました。将来の開発者が新しいファイルタイプを追加する際、MAGIC_NUMBER_MAP にエントリを追加しても、対応する if-else ブランチを追加しないと サイレントに検出スキップされます(MAX_MAGIC_SIZE の計算には使われるが、マッチングには使われないため)。

MAGIC_NUMBER_MAP の用途を MAX_MAGIC_SIZE のみに限定するか、コメントで両箇所の同期が必要であることを明示することを検討してください。

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/api/src/utils/file.ts
Line: 235-245

Comment:
**`MAGIC_NUMBER_MAP` との乖離リスク**

`MAGIC_NUMBER_MAP` はマジックナンバーの定義を持ち続けていますが、実際の判定ロジックはこの if-else チェーンに移されました。将来の開発者が新しいファイルタイプを追加する際、`MAGIC_NUMBER_MAP` にエントリを追加しても、対応する if-else ブランチを追加しないと **サイレントに検出スキップ**されます(`MAX_MAGIC_SIZE` の計算には使われるが、マッチングには使われないため)。

`MAGIC_NUMBER_MAP` の用途を `MAX_MAGIC_SIZE` のみに限定するか、コメントで両箇所の同期が必要であることを明示することを検討してください。

How can I resolve this? If you propose a fix, please make it concise.

@codecov

codecov Bot commented Apr 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Apr 14, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 2 untouched benchmarks
⏩ 15 skipped benchmarks1


Comparing staging (42d7d5b) with main (6e093cd)

Open in CodSpeed

Footnotes

  1. 15 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated Automated main-to-staging sync PR release Release promotion PR size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant