lemmy icon indicating copy to clipboard operation
lemmy copied to clipboard

[Bug]: Error 400 when commenting without explicitely setting a language

Open 0xAnansi opened this issue 1 year ago • 6 comments

Requirements

  • [X] Is this a bug report? For questions or discussions use https://lemmy.ml/c/lemmy_support
  • [X] Did you check to see if this issue already exists?
  • [X] Is this only a single bug? Do not put multiple bugs in one issue.
  • [X] Is this a backend issue? Use the lemmy-ui repo for UI / frontend issues.

Summary

When commenting on a thread that has no language set, if you don't explicitly set a language, the API returns a 400 error.

Not sure if this is by design, but I would expect a default language to be set either per user or per instance, from the list of allowed languages.

Steps to Reproduce

  1. Create a post without selecting language
  2. Comment on it without selecting language
  3. Check console

{"error":"language_not_allowed"}

Technical Details

Request:

{"content":"commentaire sans language","post_id":1406,"form_id":"markdown-form-QzncCCoW0BO1B27r6b2v","auth":"eyJ0-REDACTED"}

Response:

{"error":"language_not_allowed"}

Test post : https://jlai.lu/post/1406

Version

BE: 0.18.1-rc.4

Lemmy Instance URL

https://jlai.lu

0xAnansi avatar Jul 02 '23 10:07 0xAnansi

This is an inconsistent bug, but I've also gotten it on lemmy.world. I also keep getting user reports of it. see: https://lemmy.world/comment/822037 It seems to come and go.

Would a potential fix be to just remove language validation logic? It really hurts the user experience if they get a bogus "language not allowed" error after spending time composing a comment.

aeharding avatar Jul 04 '23 21:07 aeharding

@aeharding not sure what you're talking about when you mention consistency since I can replicate it 100% of the time. If the OP has set a language or if the instance/community allows "Undetermined", it usually does not happen.

Also, now that you mention it, I'm not sure what's the goal behind specifically asking for the language when writing comments.

0xAnansi avatar Jul 04 '23 21:07 0xAnansi

This is a pretty significant issue.

In my community, I have set the language to be English. This by itself seems fine, right? Just set your posts and comments to English.

However, today I made a post and forgot to actually set the language to English. Whatever, it's just undefined. It let me post it so what's the issue?

Well now, I can't actually reply to the post without setting a language. Again, maybe not a huge issue. If I just set the language to English it lets me reply.

This raises a few issues though:

  1. First, if I cannot comment without setting a language, why is it allowing me to make a post without a language? That by itself isn't a huge issue, but still an oddity.
  2. The question is how do we know what language to use? Yes, a client (in my case I am working on Memmy) can ask the user for a language. However, because this feature seems to be maybe not very necessary (I could just select any language I wanted to anyway without actually adhering to using that language) it would be nice to just default to whatever language is being used in the comment or post that user is replying to.

But you can't! If I assume that Ok, OP made his post using undefined. I should be able to just reply with the same, you'll end up getting this error. You would need to explicitly change your language from the language used to make the original post.

Like you said @0xAnansi it is a really weird issue, and actually from my experience is not reproducible, in my opinion, because most of the time you either just set the language or it isn't an issue to begin with. But when it is producible, there's absolutely no way around it.

Personally I feel that this shouldn't be a thing to begin with. But regardless, there needs to be consistency at the very least.

gkasdorf avatar Jul 08 '23 07:07 gkasdorf

Here's some more posts by people with this issue. It seems to come up quite often.

https://github.com/aeharding/voyager/issues/299

https://lemmy.world/post/1309563

I am confused why your posting language would ever affect whether you can post or not.

@aeharding not sure what you're talking about when you mention consistency since I can replicate it 100% of the time. If the OP has set a language or if the instance/community allows "Undetermined", it usually does not happen.

I've seen this error on lemmy.world multiple times, and that instance allows all languages including undetermined.

aeharding avatar Jul 11 '23 14:07 aeharding

(btw - is this a duplicate of #3150?)

aeharding avatar Jul 11 '23 14:07 aeharding

Just encountered again on lemmy.world. Here's the post: https://lemmy.world/post/1348987

In my language settings in my profile, I have english and unspecified selected.

Here's the post I'm trying to reply to:

image

I make a request with the following JSON (auth property not shown in image):

image

and I get back:

image image

It also fails with lemmy-ui (not just Voyager) with language = unspecified:

image

But it succeeds when I select "English" as language and submit:

image

This is a pretty severe bug.

EDIT: Going to maintain a list of reports of this issue:

  • https://lemmy.ml/post/1963239

aeharding avatar Jul 11 '23 17:07 aeharding

I cant reproduce this error message with lemmy-ui. I see some mentions of memmy, does the problem only occur with that app? That could be the case if it automatically sets a comment language which is not allowed by the community. In general it is not necessary to pass any language_id for create comment api calls.

Nutomic avatar Jul 19 '23 10:07 Nutomic

@Nutomic Did you try replying to https://lemmy.world/post/1348987 with lemmy-ui?

I'm still unable to reply to that post with language = undetermined (e.g. language_id not included in the request) from lemmy.world, just tested again.

image

image

fwiw in my profile I have languages undetermined and english selected.

aeharding avatar Jul 19 '23 13:07 aeharding

@aeharding I see the problem. That post is set to language "undetermined", so new comments will also copy that language tag. However the community only allows posts in English, not undetermined. It was probably changed after the post was created. This is indeed an edge case which the code doesnt handle properly. As a workaround you can edit the community to allow both English and undetermined.

Nutomic avatar Jul 20 '23 11:07 Nutomic

That post is set to language "undetermined", so new comments will also copy that language tag. However the community only allows posts in English, not undetermined.

Ah, yes the community is set to English!

It was probably changed after the post was created.

FWIW, I'm also able to reproduce this issue on this post that was just made:

https://lemmy.world/post/1736426

Thanks for looking into this! Hopefully 3e3473e solves this :)

aeharding avatar Jul 20 '23 13:07 aeharding