Skip to content

fix: remove hardcoded 48-character limit from text inputs#5

Open
tomerqodo wants to merge 2 commits intogreptile_full_base_fix_remove_hardcoded_48-character_limit_from_text_inputs_pr5from
greptile_full_head_fix_remove_hardcoded_48-character_limit_from_text_inputs_pr5
Open

fix: remove hardcoded 48-character limit from text inputs#5
tomerqodo wants to merge 2 commits intogreptile_full_base_fix_remove_hardcoded_48-character_limit_from_text_inputs_pr5from
greptile_full_head_fix_remove_hardcoded_48-character_limit_from_text_inputs_pr5

Conversation

@tomerqodo
Copy link
Copy Markdown

Benchmark PR from agentic-review-benchmarks#5

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Jan 26, 2026

Greptile Overview

Greptile Summary

Removed hardcoded 48-character limit (DEFAULT_VALUE_MAX_LEN) from text input configurations, making max_length optional rather than defaulting to 48. Changes include:

  • Removed DEFAULT_VALUE_MAX_LEN constant usage and fallbacks across input components
  • Removed automatic max_length assignment in variable templates (VAR_ITEM_TEMPLATE, VAR_ITEM_TEMPLATE_IN_WORKFLOW, VAR_ITEM_TEMPLATE_IN_PIPELINE)
  • Updated input components to accept undefined maxLength (no client-side restriction when not configured)
  • Changed number input type from "number" to "text" in prompt-value-panel/index.tsx:167 for consistent maxLength handling
  • Added test coverage for maxLength behavior when undefined vs defined
  • Removed obsolete test case for automatic paragraph max_length assignment

Issues found:

  • Debug console.log statement left in text-generation/index.tsx:199 (violates rule 文件拖拽功能不可用 langgenius/dify#25)
  • Critical logic bug in batch validation at text-generation/index.tsx:261: comparing length > undefined silently skips validation instead of checking if max_length exists first

Confidence Score: 2/5

  • This PR contains a critical logic bug that breaks batch CSV validation
  • The batch validation logic fails to check if max_length is defined before comparing, causing validation to be silently skipped when max_length is undefined. Additionally, a debug console.log was left in production code.
  • Pay close attention to web/app/components/share/text-generation/index.tsx which has both a logic bug and debug code

Important Files Changed

Filename Overview
web/app/components/share/text-generation/index.tsx Removed hardcoded DEFAULT_VALUE_MAX_LEN fallback, added debug console.log (should be removed), introduced logic bug in batch validation where undefined max_length causes silent validation skip
web/app/components/app/configuration/debug/chat-user-input.tsx Replaced DEFAULT_VALUE_MAX_LEN fallback with direct max_length usage, allowing undefined maxLength attributes for inputs without limits
web/app/components/share/text-generation/run-once/index.tsx Removed DEFAULT_VALUE_MAX_LEN fallback, allowing maxLength to be undefined when not configured
web/config/index.ts Removed max_length default from VAR_ITEM_TEMPLATE, VAR_ITEM_TEMPLATE_IN_WORKFLOW, and VAR_ITEM_TEMPLATE_IN_PIPELINE templates

Sequence Diagram

sequenceDiagram
    participant User
    participant UI as Input Component
    participant Config as VAR_ITEM_TEMPLATE
    participant Validation as Batch Validator

    Note over Config: Before PR: max_length = 48
    Note over Config: After PR: max_length = undefined

    User->>UI: Configure text input variable
    UI->>Config: Get default template
    Config-->>UI: Return template (no max_length)
    UI->>UI: Render input field with maxLength={undefined}
    Note over UI: HTML removes undefined maxLength<br/>allowing unlimited input

    User->>UI: Enter text in input field
    UI->>UI: No client-side length restriction

    User->>Validation: Submit batch CSV with data
    Validation->>Validation: Check if max_length exists
    alt max_length is undefined
        Validation->>Validation: length > undefined = false
        Note over Validation: Validation silently skipped!
    else max_length is defined
        Validation->>Validation: Properly validate length
    end
    Validation-->>User: Return result
Loading

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

return false
}
const headerData = data[0]
console.log('Checking batch inputs:', { dataLength: data.length, headerData })
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove debug console.log statement

Suggested change
console.log('Checking batch inputs:', { dataLength: data.length, headerData })
const headerData = data[0]

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: web/app/components/share/text-generation/index.tsx
Line: 199:199

Comment:
Remove debug `console.log` statement

```suggestion
    const headerData = data[0]
```

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

if (varItem.type === 'string') {
const maxLen = varItem.max_length || DEFAULT_VALUE_MAX_LEN
if (item[varIndex].length > maxLen) {
if (item[varIndex].length > varItem.max_length) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accessing varItem.max_length without checking if it's defined will cause a runtime error when comparing with item[varIndex].length. If max_length is undefined, the expression item[varIndex].length > undefined will always be false, which silently skips the validation check instead of throwing an error.

Add a null check before the length comparison:

if (varItem.max_length && item[varIndex].length > varItem.max_length) {
Prompt To Fix With AI
This is a comment left during a code review.
Path: web/app/components/share/text-generation/index.tsx
Line: 261:261

Comment:
Accessing `varItem.max_length` without checking if it's defined will cause a runtime error when comparing with `item[varIndex].length`. If `max_length` is `undefined`, the expression `item[varIndex].length > undefined` will always be `false`, which silently skips the validation check instead of throwing an error.

Add a null check before the length comparison:
```
if (varItem.max_length && item[varIndex].length > varItem.max_length) {
```

How can I resolve this? If you propose a fix, please make it concise.

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.

1 participant