Skip to content

Commit 279e9a9

Browse files
mattwobertsclaude
andauthored
fix(comments): raise edit limit to 4000 to match create (#1535) (#1544)
EditComment.Validate rejected content over 2000 chars while AddNewComment allowed up to 4000, so users could post a comment but not edit it. Aligns the edit cap and the matching frontend save-button gating in ShowComment to 4000, and adds a boundary test mirroring TestAddNewComment_AtMaxLength. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 8295d10 commit 279e9a9

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

app/actions/post.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ func (action *EditComment) Validate(ctx context.Context, user *entity.User) *val
348348

349349
if action.Content == "" {
350350
result.AddFieldFailure("content", propertyIsRequired(ctx, "comment"))
351-
} else if len(action.Content) > 2000 {
352-
result.AddFieldFailure("content", propertyMaxStringLen(ctx, "comment", 2000))
351+
} else if len(action.Content) > 4000 {
352+
result.AddFieldFailure("content", propertyMaxStringLen(ctx, "comment", 4000))
353353
}
354354

355355
if len(action.Attachments) > 0 {

app/actions/post_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,11 @@ func TestEditComment_TooLongContent(t *testing.T) {
158158
result := action.Validate(context.Background(), nil)
159159
ExpectFailed(result, "content")
160160
}
161+
162+
func TestEditComment_AtMaxLength(t *testing.T) {
163+
RegisterT(t)
164+
165+
action := &actions.EditComment{Content: strings.Repeat("a", 4000)}
166+
result := action.Validate(context.Background(), nil)
167+
ExpectSuccess(result)
168+
}

public/pages/ShowPost/components/ShowComment.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export const ShowComment = (props: ShowCommentProps) => {
232232
onImageUploaded={handleImageUploaded}
233233
/>
234234
<div className="mt-2">
235-
<Button size="small" onClick={saveEdit} variant="primary" disabled={newContent.length > 2000}>
235+
<Button size="small" onClick={saveEdit} variant="primary" disabled={newContent.length > 4000}>
236236
<Trans id="action.save">Save</Trans>
237237
</Button>
238238
<Button variant="tertiary" size="small" onClick={cancelEdit}>

0 commit comments

Comments
 (0)