fix: remove hardcoded 48-character limit from text inputs#5
Conversation
| if (type === PipelineInputVarType.multiFiles) | ||
| setFieldValue('maxLength', DEFAULT_FILE_UPLOAD_SETTING.max_length) | ||
| } | ||
| if (type === PipelineInputVarType.paragraph) | ||
| setFieldValue('maxLength', DEFAULT_VALUE_MAX_LEN) | ||
| }, [setFieldValue]) |
There was a problem hiding this comment.
🔴 Bug: Creating a paragraph variable in the pipeline form is broken. The Zod schema at schema.ts:43-47 requires maxLength as a non-optional z.number().min(1).max(TEXT_MAX_LENGTH) for both textInput and paragraph types, but this PR removed the auto-population of maxLength when switching to paragraph (deleted lines 88-89 in hooks.ts) and removed max_length from VAR_ITEM_TEMPLATE_IN_PIPELINE. Since the maxLength UI field is only shown for textInput (not paragraph), users have no way to set it, causing an unrecoverable validation failure when saving. Either restore the auto-set logic for paragraph, make maxLength optional in the schema for paragraph type, or add paragraph to the maxLength field's showConditions.
Extended reasoning...
What the bug is
The pipeline input field editor form uses a Zod schema (schema.ts:43-47) that requires maxLength as z.number().min(1).max(TEXT_MAX_LENGTH) for both textInput and paragraph types. This field is not optional — undefined will fail validation.
How it manifests
Before this PR, two mechanisms ensured maxLength was always populated for paragraph variables:
VAR_ITEM_TEMPLATE_IN_PIPELINEinconfig/index.tsincludedmax_length: DEFAULT_VALUE_MAX_LEN(48), providing a default when creating new variables.handleTypeChangeinhooks.ts:88-89auto-setmaxLengthtoDEFAULT_VALUE_MAX_LENwhen the user switched the type toparagraph.
This PR removed both mechanisms. It also only shows the maxLength UI field for textInput — the showConditions at hooks.ts line 131-133 only match PipelineInputVarType.textInput, not paragraph.
Step-by-step proof
- User opens the pipeline input field editor to create a new variable.
- The variable is initialized from
VAR_ITEM_TEMPLATE_IN_PIPELINE, which no longer includesmax_length, somaxLengthstarts asundefined. - User changes the type dropdown to
paragraph. handleTypeChangefires but no longer setsmaxLength(the auto-set code was deleted).- The
maxLengthform field is hidden becauseshowConditionsonly matchestextInput. - User fills in variable name, label, and other fields, then clicks Save.
- The Zod schema validates:
maxLengthisundefined, butz.number().min(1).max(256)requires a number → validation fails. - The user sees a validation error but cannot fix it because the
maxLengthfield is not visible for paragraph type.
Impact
Creating or editing paragraph-type variables in the rag-pipeline form is completely broken. The form cannot be saved, effectively blocking this functionality.
How to fix
Three possible fixes (pick one):
- Option A: Restore the auto-set logic in
handleTypeChange— when type changes toparagraph, setmaxLengthto a sensible default (e.g.,TEXT_MAX_LENGTHor some other value). - Option B: Make
maxLengthoptional in the Zod schema forparagraphtype (e.g.,maxLength: z.number().min(1).max(TEXT_MAX_LENGTH).optional()). - Option C: Add
PipelineInputVarType.paragraphto theshowConditionsfor themaxLengthfield in the configurations, so users can set it manually.
Option A is probably the simplest and most consistent with the original behavior.
| return false | ||
| } | ||
| const headerData = data[0] | ||
| console.log('Checking batch inputs:', { dataLength: data.length, headerData }) |
There was a problem hiding this comment.
🔴 Debug console.log("Checking batch inputs:", ...) left in production code at line 199. This logs user batch input data (headers and data length) to the browser console on every batch submission and should be removed before merging.
Extended reasoning...
What the bug is
A console.log statement was added at line 199 of web/app/components/share/text-generation/index.tsx inside the checkBatchInputs function:
console.log("Checking batch inputs:", { dataLength: data.length, headerData })This is debug logging that was accidentally left in the PR.
Code path that triggers it
The checkBatchInputs function is called by handleRunBatch whenever a user submits a batch of inputs in the shared text generation view. Every single batch submission will trigger this console.log, printing the batch header data (which contains user-defined variable names and potentially sensitive column headers) to the browser console.
Why existing code doesn't prevent it
The project has an ESLint no-console warning rule (referenced in AGENTS.md rule qodo-benchmark#25: "Frontend Code Must Not Use console Statements"), but since it's configured as a warning rather than an error, it doesn't block the build or fail CI. This allowed the statement to slip through.
Impact
In production, this console.log will:
- Add noise to the browser developer console for every batch submission
- Log user batch input data (
headerData) which could contain sensitive information depending on the application's prompt variables - Violate the project's coding standards (AGENTS.md rule [CLEAN] Synthetic Benchmark PR #29179 - chore: update TypeScript type-check command and add native-preview dependency for faster performance dify#25)
While not a crash-level bug, it's unprofessional for production code and represents a minor data exposure concern.
Step-by-step proof
- User navigates to a shared text generation app and switches to the "batch" tab
- User uploads a CSV file with batch inputs and clicks Run
handleRunBatchis called, which callscheckBatchInputs(data)- At line 199,
console.log("Checking batch inputs:", { dataLength: data.length, headerData })executes - The browser console displays the batch data length and the full header row from the CSV, which includes all prompt variable names and their values
How to fix
Simply remove line 199:
- console.log("Checking batch inputs:", { dataLength: data.length, headerData })| {type === 'number' && ( | ||
| <Input | ||
| type="number" | ||
| type="text" |
There was a problem hiding this comment.
🔴 The input type for number fields was changed from type="number" to type="text" at line 167, which is unrelated to the PR goal of removing the 48-character limit. This loses browser-native numeric validation (numeric keyboard on mobile, spinner controls, rejection of non-numeric characters), allowing users to enter arbitrary text into numeric fields. The other file handling number inputs (chat-user-input.tsx:113) correctly keeps type="number", confirming this was accidental.
Extended reasoning...
What the bug is
In web/app/components/app/configuration/prompt-value-panel/index.tsx at line 167, the type attribute on the <Input> component for number fields was changed from "number" to "text". This change is bundled with the legitimate maxLength changes but is unrelated to the PR's goal of removing the hardcoded 48-character limit.
How it manifests
When a user configures a prompt variable of type number in the prompt value panel, the input field will now accept any arbitrary text—letters, symbols, special characters—rather than constraining input to numeric values. On mobile devices, users will see a full text keyboard instead of the numeric keypad, and on desktop browsers, the native spinner controls for incrementing/decrementing values will be absent.
The specific code path
The prompt value panel iterates over promptVariables and renders different input types based on the variable's type field. For type === 'number', the code at line 167 renders <Input type="text" ...> instead of <Input type="number" ...>. This means the HTML <input> element loses its type="number" attribute, which is what triggers browser-native numeric validation.
Why existing code doesn't prevent it
There is no JavaScript-level numeric validation on the onChange handler for number inputs—it simply passes e.target.value directly to handleInputValueChange. The code relied entirely on the browser's native type="number" behavior to restrict input to numeric values. With type="text", there is no validation at all.
Inconsistency with other files
The companion file chat-user-input.tsx at line 113 correctly keeps type="number" for the same kind of number input field. This inconsistency strongly suggests the change in prompt-value-panel/index.tsx was accidental. One possible explanation is that the author changed it to make the HTML maxLength attribute work (since maxLength is ignored on type="number" inputs per the HTML spec), but since max_length is typically undefined for number fields after this PR removes defaults, the maxLength prop would be undefined/no-op anyway.
Step-by-step proof
- A user creates a prompt variable of type
numberin the app configuration. - The prompt value panel renders the input using the code at line 167:
<Input type="text" ...>. - The user clicks on the number input field and types
abc123!@#. - Because
type="text"accepts any characters, the full stringabc123!@#is accepted and stored as the input value. - This invalid non-numeric value is then passed downstream when the prompt is executed, potentially causing errors or unexpected behavior.
- In contrast, the same scenario in
chat-user-input.tsx(which keepstype="number") would reject non-numeric characters at the browser level.
How to fix
Revert line 167 from type="text" back to type="number". This restores browser-native numeric validation and maintains consistency with chat-user-input.tsx.
| placeholder={name} | ||
| value={inputs[key] ? `${inputs[key]}` : ''} | ||
| onChange={(e) => { handleInputValueChange(key, e.target.value) }} | ||
| maxLength={max_length} | ||
| /> |
There was a problem hiding this comment.
🔴 Adding maxLength={max_length} to the paragraph Textarea in chat-user-input.tsx (line 99) introduces a regression for existing paragraph variables. Before this PR, the old config-modal auto-set max_length=48 when switching to paragraph type, but this value was never enforced on paragraph textareas. Now existing paragraph variables with stored max_length: 48 will suddenly be limited to 48 characters — an extremely restrictive limit for a paragraph field. Additionally, prompt-value-panel/index.tsx and run-once/index.tsx do NOT have maxLength on their paragraph Textareas, creating inconsistent enforcement across views.
Extended reasoning...
What the bug is
This PR adds maxLength={max_length} to the paragraph Textarea in chat-user-input.tsx (line 99). Before this PR, the paragraph textarea had no maxLength prop at all. While this change works correctly for new paragraph variables (where max_length is undefined, so maxLength={undefined} means no limit), it creates a regression for existing paragraph variables.
How it manifests — step-by-step proof
- Before this PR, when a user switched a variable to paragraph type in the config modal,
handleTypeChangeauto-setmax_length = DEFAULT_VALUE_MAX_LEN(48). This value was stored in the backend/variable config. - Before this PR, the paragraph
Textareainchat-user-input.tsxhad NOmaxLengthprop, so users could type unlimited text — the storedmax_length: 48was decorative. - This PR correctly removes the auto-set of
max_length=48for new paragraph variables (inconfig-modal/index.tsx), and removesmax_lengthfromVAR_ITEM_TEMPLATE(inconfig/index.ts). - However, this PR also adds
maxLength={max_length}to the paragraphTextareainchat-user-input.tsx. - For any existing paragraph variable that was created before this PR and has
max_length: 48stored in the database,maxLength={48}is now enforced on the textarea. - A 48-character limit on a paragraph field (designed for multi-line, long-form text) is extremely restrictive and breaks the expected user experience.
Inconsistency across views
The enforcement is also inconsistent across the three views that render paragraph textareas:
chat-user-input.tsx(line 99): HasmaxLength={max_length}— newly added by this PR, enforces the limitprompt-value-panel/index.tsx(lines 148-153): NomaxLengthon paragraph Textarea — does NOT enforce the limitrun-once/index.tsx(lines 146-151): NomaxLengthon paragraph Textarea — does NOT enforce the limit
This means the same paragraph variable would have a 48-character limit in the chat debug panel but unlimited text in the completion prompt value panel and the shared text-generation form.
Impact
Any existing app with paragraph variables created before this PR will have those variables suddenly limited to 48 characters in the chat debug interface. Users who previously typed long paragraphs will find their input truncated. The PR title says it removes hardcoded limits, but this change paradoxically introduces enforcement that did not exist before.
Suggested fix
Either:
- Remove
maxLengthfrom the paragraphTextareainchat-user-input.tsx(matching the other two views and the old behavior), or - Add
maxLengthto paragraph textareas in all three views for consistency, AND include a migration or runtime guard to clear stalemax_lengthvalues (e.g., treatmax_length: 48asundefinedfor paragraph types).
Benchmark PR from agentic-review-benchmarks#5