misskey-dev / misskey

🌎 A completely free and open interplanetary microblogging platform πŸš€
https://misskey-hub.net/
GNU Affero General Public License v3.0
10.14k stars 1.38k forks source link

regression: some API endpoints now requires an empty JSON object as the parameter #9388

Open saschanaz opened 1 year ago

saschanaz commented 1 year ago

πŸ’‘ Summary

Some endpoints don't have a required parameter but still asks an object as a POST body

πŸ₯° Expected Behavior

Don't ask the body

🀬 Actual Behavior

It does

πŸ“ Steps to Reproduce

  1. curl -X POST https://misskey.io/api/meta
  2. curl -X POST https://p1.a9z.dev/api/meta
  3. curl -X POST -H "Content-Type: application/json" -d "{}" https://p1.a9z.dev/api/meta

1 and 3 succeeds, 2 fails.

πŸ“Œ Environment

Misskey version: 12.x vs 13.x Your OS: Windows 11 Your browser: Firefox

saschanaz commented 1 year ago

See also: #9355

tamaina commented 1 year ago

curl -X POST -H "Content-Type: application/json" https://p1.a9z.dev/api/metaは {"statusCode":400,"code":"FST_ERR_CTP_EMPTY_JSON_BODY","error":"Bad Request","message":"Body cannot be empty when content-type is set to 'application/json'"} γͺγ‚“γ γ‘γ©θ¦ζ Όγ¨γ―γ„γˆγ‘γ‚‡γ£γ¨εŽ³γ—γ„γ¨γ“γ‚γ§γ―γ‚γ‚‹

saschanaz commented 1 year ago

Probably because b75184ec8e3436200bacdcd832e3324702553d20 added validate() on endpoint-base.ts and each meta indeed requires an object:

https://github.com/misskey-dev/misskey/blob/52cbe07a780c0542912798e1e9bc1b78a63d6806/packages/backend/src/server/api/endpoint-base.ts#L48

https://github.com/misskey-dev/misskey/blob/f1fd1d2585bd5230caea4c7b8814c2cf007e57cc/packages/backend/src/server/api/endpoints/meta.ts#L309-L315

saschanaz commented 1 year ago

γγ‚Œγ¨γ€γ“γ†γ„γ†APIはGETγ«γ‚‚ε―ΎεΏœγ™γ‚‹ζ–ΉγŒγƒ¦γƒΌγ‚ΆγƒΌγ¨γ—γ¦γ―ζ₯½γ γ¨ζ€γ„ます