Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear message text when message property is too long #27059

Open
pmokeev opened this issue May 18, 2024 · 2 comments
Open

Unclear message text when message property is too long #27059

pmokeev opened this issue May 18, 2024 · 2 comments
Assignees
Labels
Help Wanted Community help wanted

Comments

@pmokeev
Copy link
Contributor

pmokeev commented May 18, 2024

Summary

When I'm trying to post a message which contains mattermost.PostMessageMaxRunesV2 + 1 of symbols, I receive "invalid message" error, which is definitely unclear what is exactly invalid in my message. I see that the code contains a check for the length of the message which is being sent, but then it maps to "Invalid message" message using i18 json files, the text of which seems too general. Moreover, searching for more codebase I found that there is another message error, which specifies information about message length.

So my proposal is to rename model.post.is_valid.msg.app_error error to something like model.post.is_valid.message_length.app_error and the mapping message to Post Message property is longer than the maximum permitted length.

Steps to reproduce

import (
	"context"
	"strings"

	mattermost "github.com/mattermost/mattermost/server/public/model"
)

func main() {
	mattermostClient := mattermost.NewAPIv4Client("http://localhost:8065")
	mattermostClient.SetToken("SOME_TOKEN")

	msg := mattermost.Post{
		ChannelId: "SOME_CHANNEL_ID",
		Message:   strings.Repeat("!", mattermost.PostMessageMaxRunesV2+1),
	}

	_, _, err := mattermostClient.CreatePost(context.TODO(), &msg)
	if err != nil {
		panic(err)
	}
}

Expected behavior

panic: Post Message property is longer than the maximum permitted length.

Observed behavior (that appears unintentional)

panic: Invalid message.

Possible fixes

  • Rename model.post.is_valid.msg.app_error to model.post.is_valid.message_length.app_error
  • Rename Invalid message mapping error text to Post Message property is longer than the maximum permitted length.

WDYT? I can create a PR by my own to solve this issue.

@pmokeev
Copy link
Contributor Author

pmokeev commented May 18, 2024

It seems that model.draft.is_valid.msg.app_error has similar behaviour - Link

@amyblais
Copy link
Member

Feel free to open a PR for this!

@amyblais amyblais added the Help Wanted Community help wanted label May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted Community help wanted
Projects
None yet
Development

No branches or pull requests

2 participants