Validate and bound plugin settings requests - #5
Merged
Conversation
Co-authored-by: carochacs <79524656+carochacs@users.noreply.github.com>
Co-authored-by: carochacs <79524656+carochacs@users.noreply.github.com>
Co-authored-by: carochacs <79524656+carochacs@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix unvalidated JSON body in settings POST endpoint
Validate and bound plugin settings requests
Aug 6, 2026
carochacs
marked this pull request as ready for review
August 6, 2026 16:50
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@my-plugin/routes.py`:
- Around line 88-136: The async set_settings handler performs blocking
filesystem work directly; move every _read(), config_dir.mkdir(), and
config_file.write_text() invocation to asyncio.to_thread and await the results.
Preserve the existing bounded-body validation and settings-update behavior while
ensuring no synchronous filesystem operation runs on the event loop.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4b1a8352-e1a1-421c-9969-41141d74cbcd
📒 Files selected for processing (2)
my-plugin/routes.pymy-plugin/settings.html
set_settings must stay async def to stream the request body, but the read-merge-write it did directly (_read(), config_dir.mkdir(), config_file.write_text()) are blocking filesystem calls that would block every concurrent request while a settings update is in flight. Wrapped the merge+persist step in asyncio.to_thread(), matching this repo's convention for keeping blocking work off the event loop (CodeRabbit).
carochacs
approved these changes
Aug 8, 2026
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.
The template accepted arbitrary JSON settings bodies and persisted unknown, nested, or oversized values. This adds bounded request handling and a strict schema for the template’s settings.
Request limits
Content-Lengthvalues.Settings schema
color,intensity, andenable_animations.0–10, and boolean animation state.Client alignment
enable_animationsusing the server key.Greptile Summary
The PR bounds settings request bodies at 16 KiB and introduces strict validation for accepted and persisted values.
Confidence Score: 5/5
The PR appears safe to merge with no concrete correctness or security failures identified.
The request-size limit remains enforced for bodies with or without a usable Content-Length header, persisted values are normalized as described, and the frontend now submits keys and types accepted by the backend.
Important Files Changed
Reviews (1): Last reviewed commit: "Sanitize invalid JSON errors" | Re-trigger Greptile