-
Notifications
You must be signed in to change notification settings - Fork 0
fix: Add validation for required body in CustomizePostDialog #46
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
f387180
dadf937
30d8137
53b6208
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,18 +272,18 @@ function validateBody(input: PreflightInput): ValidationIssue[] { | |
| if (!reqs) continue; | ||
|
|
||
| // Body required check | ||
| if (reqs.body_restriction_policy === 'required' && !body.trim()) { | ||
| issues.push({ | ||
| code: 'BODY_REQUIRED', | ||
| severity: 'error', | ||
| subreddit, | ||
| message: `r/${subreddit} requires a description`, | ||
| suggestion: 'Add a description to your post', | ||
| field: 'body', | ||
| expectedCategory: 'fixable_now', | ||
| }); | ||
| continue; | ||
| } | ||
| // if (reqs.body_restriction_policy === 'required' && !body.trim()) { | ||
| // issues.push({ | ||
| // code: 'BODY_REQUIRED', | ||
| // severity: 'error', | ||
| // subreddit, | ||
| // message: `r/${subreddit} requires a description`, | ||
| // suggestion: 'Add a description to your post', | ||
| // field: 'body', | ||
| // expectedCategory: 'fixable_now', | ||
| // }); | ||
| // continue; | ||
| // } | ||
|
Comment on lines
+275
to
+286
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restore server-side/preflight Line 275-Line 286 currently bypasses required-body validation by commenting out the check. This regresses preflight guarantees and allows invalid payloads to pass 🔧 Proposed fix- // Body required check
- // if (reqs.body_restriction_policy === 'required' && !body.trim()) {
- // issues.push({
- // code: 'BODY_REQUIRED',
- // severity: 'error',
- // subreddit,
- // message: `r/${subreddit} requires a description`,
- // suggestion: 'Add a description to your post',
- // field: 'body',
- // expectedCategory: 'fixable_now',
- // });
- // continue;
- // }
+ // Body required check
+ if (reqs.body_restriction_policy === 'required' && !body.trim()) {
+ issues.push({
+ code: 'BODY_REQUIRED',
+ severity: 'error',
+ subreddit,
+ message: `r/${subreddit} requires a description`,
+ suggestion: 'Add a description to your post',
+ field: 'body',
+ expectedCategory: 'fixable_now',
+ });
+ continue;
+ }As per coding guidelines, "Never bypass validation" and "Always validate inputs." 🤖 Prompt for AI Agents |
||
|
|
||
| // Min length (only if body exists) | ||
| if (body && reqs.body_text_min_length && body.length < reqs.body_text_min_length) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commenting out this branch removes the only global check that blocks submissions when a subreddit requires a description, so
validatePreflightcan now returncanProceed=truefor empty bodies and the queue/review flow will allow posting until Reddit rejects it downstream. The new inline check inCustomizePostDialogdoes not cover this because it only runs if that dialog is opened (and customization is gated by paid/trial inpages/index.tsx), so free users and any non-customized subreddit path lose required-body protection entirely.Useful? React with 👍 / 👎.