Skip to content

fix: reject AI form value not matching field value type - #10619

Merged
tomivirkki merged 1 commit into
mainfrom
fix/reject-ai-form-value-not-matching
Nov 9, 2026
Merged

tomivirkki merged 1 commit into
mainfrom
fix/reject-ai-form-value-not-matching

Conversation

@tomivirkki

Copy link
Copy Markdown
Member

Description

Follow-up to #10569
Related to #10569 (comment)

FormAIController passed the converted fill_form value to setValue without checking it against the field's value type. A field whose value type has no type mapping, such as UUID, is listed as a string field, so it got a String. The field accepted it and the app failed later with a ClassCastException. #10569 fixed this for number fields; this change adds a general check for all fields.

  • Added a check after conversion that compares the value with the field's HasValue<?, V> value type
    • A value that does not match is rejected with "Field cannot be filled: its value type is not supported." and the field keeps its old value. The types are logged at debug level.
    • Fields whose value type cannot be resolved, such as a generic ComboBox<T>, are not checked.
  • Resolved parameterized value types such as List<String> to their raw class, so these fields are also checked. Field classification does not change.
  • Added tests for a UUID field including the debug log, a List field, and a select field whose items contain null

Type of change

  • Bugfix

@vaadin-review-bot vaadin-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

✅ Nothing to flag — the changes look good.

@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

@sissbruecker
sissbruecker self-requested a review November 9, 2026 11:48
@tomivirkki
tomivirkki added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 1cbab52 Nov 9, 2026
20 checks passed
@tomivirkki
tomivirkki deleted the fix/reject-ai-form-value-not-matching branch November 9, 2026 12:48
vaadin-bot added a commit that referenced this pull request Nov 9, 2026
… 25.3) (#10620)

This PR cherry-picks changes from the original PR #10619 to branch 25.3.

---

> ## Description
> 
> Follow-up to #10569
> Related to
#10569 (comment)
> 
> `FormAIController` passed the converted `fill_form` value to
`setValue` without checking it against the field's value type. A field
whose value type has no type mapping, such as `UUID`, is listed as a
string field, so it got a `String`. The field accepted it and the app
failed later with a `ClassCastException`. #10569 fixed this for number
fields; this change adds a general check for all fields.
> 
> - Added a check after conversion that compares the value with the
field's `HasValue<?, V>` value type
> - A value that does not match is rejected with "Field cannot be
filled: its value type is not supported." and the field keeps its old
value. The types are logged at debug level.
> - Fields whose value type cannot be resolved, such as a generic
`ComboBox<T>`, are not checked.
> - Resolved parameterized value types such as `List<String>` to their
raw class, so these fields are also checked. Field classification does
not change.
> - Added tests for a `UUID` field including the debug log, a `List`
field, and a select field whose items contain `null`
> 
> ## Type of change
> 
> - Bugfix
>

Co-authored-by: Tomi Virkki <tomivirkki@users.noreply.github.com>
@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 25.4.0-alpha6.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants