fix: add input validation for input_text in form fill#478
Open
krrishrastogi05 wants to merge 1 commit intofireform-core:mainfrom
Open
fix: add input validation for input_text in form fill#478krrishrastogi05 wants to merge 1 commit intofireform-core:mainfrom
krrishrastogi05 wants to merge 1 commit intofireform-core:mainfrom
Conversation
- Backend: add @field_validator on FormFill to reject empty/whitespace and inputs exceeding 10,000 characters (returns 422) - Frontend: add max-length guard before submission to surface error without a round trip
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.
Summary
POST /forms/fillaccepted any string forinput_text— including empty strings and whitespace-only input. This caused Ollama to be called once per template field with no useful content, wasting LLM cycles and writing a useless PDF to disk.Changes
api/schemas/forms.py— added@field_validatoronFormFill.input_textto reject empty/whitespace input and strings over 10,000 characters. Returns422automatically before the request reaches the controller.frontend/app.js— added max-length guard alongside the existing empty-string check so users get immediate feedback without a round trip.Why both layers
Frontend validation improves UX for normal users. Backend validation is the real enforcement — it protects the API from curl, Swagger, and any future integrations that bypass the UI.
Testing
POST /forms/fillwith""or" "→422POST /forms/fillwith string > 10,000 chars →422/docsFixes issue: #477