fix: reddit settings type only accepts self, link, media - #1915
Merged
Merged
Conversation
The Reddit DTO advertised type as link/self/image/video/videogif, but the provider only implements self, link and media (upload the first attached file). Other values were forwarded to Reddit as kind without a file and always failed with BAD_URL. Validate type with @isin and fix the public API / MCP schema description. Also initialise url to '' when a subreddit is picked in the composer, so the URL input is controlled from mount (fixes the React uncontrolled to controlled warning) and empty link URLs are validated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Strix Security ReviewNo security issues found. Updated for Reviewed by Strix |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Bug fix (backend DTO + frontend, Reddit settings). Constrains
RedditSettingsDtoInner.typeto@IsIn(['self', 'link', 'media'])instead of@MinLength(2), corrects its@JSONSchemadescription to describe what those three values actually do, and seedsurl: ''when a subreddit is added insubreddit.tsxso the field always exists. Flag for the reviewer:RedditProviderstill mapsimage,videoandvideogifas valid kinds, so existing drafts and public-API callers using those values would start failing validation - they should be added to theIsInlist. Theurl: ''seed also makes@IsUrl()fire immediately on subreddits that only allow link posts, where it was previously skipped.Why was this change needed?
The Reddit settings DTO advertised
typeas "link, self, image, video, videogif", but the provider only implementsself,linkandmedia(upload the post's first attached image or mp4). Any other value was forwarded to Reddit askindwithout a file, soimage/videoposts always failed at publish time with Reddit'sBAD_URL "The image URL can't be empty". A customer creating Reddit posts through the public API hit this for weeks with every post failing.Now:
typeis validated with@IsIn(['self', 'link', 'media']), so unknown values fail with a 400 at request time instead of silently failing at Reddit.integrationSchemaexpose) lists the real values.urlto''when a subreddit is picked, so the URL input is controlled from mount (removes a React "uncontrolled to controlled" console error) and an empty link URL is now validated.Note:
text(used by the old postiz-agent skill; it fell back toself) is now rejected. Companion PRs update the docs and the agent skill:Those two should only be merged after this PR is deployed to production.
Other information:
Tested:
type: imageandtype: textreturn 400 mentioningtype;selfandlink(with url) are accepted;mediawith an attached PNG published successfully to a real Reddit channel.QA
"type": "banana"- returns 400 naming the allowed values"type": "image"- confirm whether the 400 is intended, because this succeeds todayChecklist:
🤖 Generated with Claude Code