Skip to content

fix(backend): /api-doc にアクセスできない問題を修正#17267

Merged
syuilo merged 6 commits intodevelopfrom
copilot/fix-api-doc-access-error
Apr 1, 2026
Merged

fix(backend): /api-doc にアクセスできない問題を修正#17267
syuilo merged 6 commits intodevelopfrom
copilot/fix-api-doc-access-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

What

Fix staticAssets path resolution in OpenApiServerService.ts to use the same root-finding approach already used in ClientServerService.ts.

Why

PR #17054 (minify backend) switched the build from per-file tsc output to a single esbuild bundle at built/boot/entry.js. OpenApiServerService.ts was still resolving the assets path relative to import.meta.url:

// Before: breaks when bundled — import.meta.url is now built/boot/entry.js,
// so ../../../../assets/ walks up to repo root, not packages/backend/
const staticAssets = fileURLToPath(new URL('../../../../assets/', import.meta.url));

ClientServerService.ts was updated in the same PR to walk up the tree to find the repo root, but OpenApiServerService.ts was missed, causing reply.sendFile('/api-doc.html', staticAssets) to look in the wrong directory and return 404.

// After: resolves correctly regardless of bundle location
let rootDir = _dirname;
while (!fs.existsSync(resolve(rootDir, 'packages'))) {
    const parentDir = dirname(rootDir);
    if (parentDir === rootDir) throw new Error('Cannot find root directory');
    rootDir = parentDir;
}
const staticAssets = resolve(rootDir, 'packages/backend/assets');

Additional info (optional)

Related: #17054 introduced the build change; /api.json was unaffected since it generates content dynamically.

Checklist

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

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Fix 404 error when accessing /api-doc fix: /api-doc returns 404 due to broken path resolution after backend bundling Mar 28, 2026
Copilot AI requested a review from syuilo March 28, 2026 01:24
@github-actions github-actions bot added the packages/backend Server side specific issue/PR label Mar 28, 2026
@syuilo
Copy link
Copy Markdown
Member

syuilo commented Mar 28, 2026

/preview

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 28, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.74%. Comparing base (9377e94) to head (e390036).
⚠️ Report is 18 commits behind head on develop.

Files with missing lines Patch % Lines
...end/src/server/api/openapi/OpenApiServerService.ts 87.50% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #17267      +/-   ##
===========================================
- Coverage    63.57%   61.74%   -1.83%     
===========================================
  Files         1161     1161              
  Lines       116244   116324      +80     
  Branches      8371     8062     -309     
===========================================
- Hits         73900    71824    -2076     
- Misses       40159    42314    +2155     
- Partials      2185     2186       +1     

☔ 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.

@kakkokari-gtyih kakkokari-gtyih marked this pull request as ready for review April 1, 2026 03:46
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

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

@kakkokari-gtyih kakkokari-gtyih changed the title fix: /api-doc returns 404 due to broken path resolution after backend bundling fix: /api-doc にアクセスできない問題を修正 Apr 1, 2026
@kakkokari-gtyih kakkokari-gtyih changed the title fix: /api-doc にアクセスできない問題を修正 fix(backend): /api-doc にアクセスできない問題を修正 Apr 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

Backend memory usage comparison

Before GC

Metric base (MB) head (MB) Diff (MB) Diff (%)
VmRSS 315.09 MB 326.96 MB +11.86 MB +3.76%
VmHWM 315.09 MB 326.96 MB +11.86 MB +3.76%
VmSize 23108.92 MB 23118.51 MB +9.58 MB +0.04%
VmData 1378.72 MB 1389.10 MB +10.37 MB +0.75%

After GC

Metric base (MB) head (MB) Diff (MB) Diff (%)
VmRSS 315.09 MB 326.96 MB +11.86 MB +3.76%
VmHWM 315.09 MB 326.96 MB +11.86 MB +3.76%
VmSize 23108.92 MB 23118.51 MB +9.58 MB +0.04%
VmData 1378.72 MB 1389.10 MB +10.37 MB +0.75%

After Request

Metric base (MB) head (MB) Diff (MB) Diff (%)
VmRSS 315.41 MB 327.33 MB +11.92 MB +3.77%
VmHWM 315.41 MB 327.33 MB +11.92 MB +3.77%
VmSize 23108.92 MB 23118.51 MB +9.58 MB +0.04%
VmData 1378.72 MB 1389.10 MB +10.37 MB +0.75%

See workflow logs for details

@kakkokari-gtyih
Copy link
Copy Markdown
Contributor

なおした

@syuilo syuilo merged commit 5361a38 into develop Apr 1, 2026
4 checks passed
@syuilo
Copy link
Copy Markdown
Member

syuilo commented Apr 1, 2026

🙏🏻

@syuilo syuilo deleted the copilot/fix-api-doc-access-error branch April 1, 2026 05:43
@github-project-automation github-project-automation bot moved this from Todo to Done in [実験中] 管理用 Apr 1, 2026
m10i-0nyx pushed a commit to foundation0-link/misskey that referenced this pull request Apr 12, 2026
* Initial plan

* fix: fix /api-doc returning 404 after backend minification (misskey-dev#17266)

Agent-Logs-Url: https://github.com/misskey-dev/misskey/sessions/8d7d0585-55da-412f-a8ee-dde1b6565026

Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>

* enhance: API DocのHTMLをJSXで生成するように

* Update Changelog

* chore: remove unused imports [ci skip]

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
Co-authored-by: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com>
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:M This PR changes 30-99 lines, ignoring generated files.

Projects

Development

Successfully merging this pull request may close these issues.

/api-docにアクセスできない

3 participants