misskey-dev / misskey

🌎 An interplanetary microblogging platform 🚀
https://misskey-hub.net/
GNU Affero General Public License v3.0
9.8k stars 1.32k forks source link

content warning length limit #8777

Open tastytea opened 2 years ago

tastytea commented 2 years ago

💡 Summary

I wanted to reply to a note but got the error “Invalid param” with no further explanation. Turns out i can't reply to notes with content warnings with more than 100 characters.

Mastodon does not have a limit, so content warnings could be 499 chars on a normal instance and much longer on instances with higher overall character limit.

🥰 Expected Behavior

I can reply to the note with the CW intact.

🤬 Actual Behavior

Error popup with “Invalid param”.

📝 Steps to Reproduce

  1. Post a toot in Mastodon with a CW that is 101 characters long
  2. Try to reply to it from Misskey
  3. :boom:

📌 Environment

Misskey version: 12.110.1 Your OS: Gentoo Linux Your browser: Firefox 91.9.1esr

Johann150 commented 2 years ago

Can you try replying if you remove or shorten the content warning on your reply?

tastytea commented 2 years ago

Can you try replying if you remove or shorten the content warning on your reply?

Yes, removing or shortening the CW works.

Johann150 commented 2 years ago

Then the issue is not about being able to reply, since it is possible.

It might be a good idea to detect the particular error in the client to show a better error message.

tastytea commented 2 years ago

Then the issue is not about being able to reply, since it is possible.

Well, yeah. If you know what the error is and if you're willing to truncate metadata.

It might be a good idea to detect the particular error in the client to show a better error message.

The response to POST /api/notes/create was 400 Bad Request with this body:

{
    "error": {
        "message": "Invalid param.",
        "code": "INVALID_PARAM",
        "id": "3d81ceae-475f-4600-b2a8-2bc126157542",
        "kind": "client",
        "info": {
            "param": "#/properties/cw/maxLength",
            "reason": "must NOT have more than 100 characters"
        }
    }
}

Maybe the info part could be included in the popup?

I get that there has to be some kind of limit, but maybe it should be a little higher? Or not apply to replies?

Johann150 commented 2 years ago

Maybe the info part could be included in the popup?

I was thinking of checking exactly that info part and if it has the value as above, then show a more specific message (that can also be internationalized).

I get that there has to be some kind of limit, but maybe it should be a little higher?

I am not familiar why the limit is what it is. Going back in the commit history I got to this point https://github.com/misskey-dev/misskey/blame/59785ea04cee105ac0188c5090f81b570c0c2b08/packages/backend/src/models/repositories/note.ts#L15-L17 although I think that it might have been present at an earlier date as well. That commit was made by @syuilo, so maybe he can comment on why the length is 100. My own opinion is also that it is a bit short.

Or not apply to replies?

That will not work with the API validators.

syuilo commented 2 years ago

Since it is intended to be used as a short annotation, 100 characters should be sufficient.

tastytea commented 2 years ago

I looked around a bit, and found no other content warnings over 100 characters, most are way shorter. It seems to me that a higher limit would not lead to everyone making use of it, but it would increase compatibility in rare cases.

4ioskd commented 2 years ago

*These English/Japanese sentences are same meaning.

(240 characters) First of all, it takes about twice as many characters to write a sentence in English as it does in Japanese. It is true that writing more than 100 characters in CW in Japanese may be a rare case, but it may be insufficient in English.

(99 characters) そもそも日本語で文章を書くのと比べ英語の場合、約2倍程度の文字数を必要とします。確かにCWで100文字以上を日本語で書くことはレアケースかもしれませんが、英語では不足することはあるかもしれません。

Johann150 commented 2 years ago

related: #7211

KisaragiEffective commented 1 month ago

triage: 生きている。

折衷案: UTF-8換算で300バイトまでに制限するのはどうでしょう?

anatawa12 commented 1 month ago

FYI: db的には上限は512になってる