Skip to content

Add validation for input_text in fill_form endpoint#377

Open
Lochit-Vinay wants to merge 2 commits intofireform-core:mainfrom
Lochit-Vinay:validate-input-text
Open

Add validation for input_text in fill_form endpoint#377
Lochit-Vinay wants to merge 2 commits intofireform-core:mainfrom
Lochit-Vinay:validate-input-text

Conversation

@Lochit-Vinay
Copy link
Copy Markdown

Closes #376

Summary

Added validation for input_text in the fill_form endpoint to prevent empty or whitespace-only input.

Problem

The endpoint allowed empty or whitespace-only input_text, which could lead to:

  • Unnecessary processing
  • Unexpected behavior in downstream components

Before

fetched_template = get_template(db, form.template_id)

Solution

Added input validation at the beginning of the function:

After

if not form.input_text.strip():
    raise AppError("Input text cannot be empty", status_code=400)

fetched_template = get_template(db, form.template_id)

Benefits

  • Prevents invalid requests
  • Improves API robustness
  • Reduces unnecessary processing
  • Ensures early validation, preventing unnecessary downstream execution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate input_text in fill_form endpoint

1 participant