Skip to content

test(a2ui_flutter): cover the properties an agent gets wrong - #4108

Open
diegolopezrm wants to merge 4 commits into
a2ui-project:mainfrom
diegolopezrm:test/a2ui-flutter-tolerant-reads
Open

diegolopezrm wants to merge 4 commits into
a2ui-project:mainfrom
diegolopezrm:test/a2ui-flutter-tolerant-reads

Conversation

@diegolopezrm

Copy link
Copy Markdown
Contributor

Part of #2872, as @yjbanov suggested there: every case from flutter/genui#1050 and from the issue, now as tests on a2ui_flutter's v0.9 and v1.0 basic catalogs.

None of them crash a2ui_flutter. A literal of the wrong type never reaches a widget, since a2ui_core rejects it against the schema, so those tests check that the update is rejected, reported on onError, and that the surface keeps what it showed. A value that arrives through a binding isn't schema-checked, and those fall back without throwing.

Trying nearby inputs found one that does crash: a Slider with "min": -1e400, which JSON decodes to negative infinity and fails a Material assertion. The second commit treats an infinite min or max as absent, the way an HTML range input does. Happy to move it to its own PR if you'd rather.

Ports the cases from flutter/genui#1050 and a2ui-project#2872 to the v0.9 and v1.0
basic catalogs: Slider, TextField, DateTimeInput and Tabs.

A literal of the wrong type does not reach a widget here. The processor
checks it against the component's schema, even without a validation
config, and rejects the update, so those cases check that it is
rejected, reported on the surface's onError, and that the surface keeps
what it showed. What a bound path holds is not checked, so the values a
widget has to survive are bound, and each one falls back instead of
throwing. The two schema-valid Slider payloads from a2ui-project#2872, a value above
max and a max below min, stay literals.
A JSON number past the largest double, such as -1e400, decodes to an
infinity, and the schema accepts it as a number. With a min of negative
infinity the Material Slider normalises its value to NaN and fails the
assertion 'value >= 0.0 && value <= 1.0' while building.

An infinite min or max now falls back to its default, 0 or 100, which is
what an HTML range input does with the same attribute.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Slider component in a2ui_flutter to treat infinite min or max values (which can result from decoding extreme JSON numbers like -1e400) as absent, falling back to default values. It also introduces comprehensive tests in tolerant_reads_test.dart and v1_0_test.dart to verify how various components (such as Slider, TextField, DateTimeInput, and Tabs) handle invalid or unexpected bound types. As there are no review comments, I have no additional feedback to provide.

@github-actions github-actions Bot added the status: needs-triage auto-managed: https://github.com/a2ui-project/a2ui/blob/main/scripts/triage.mjs label Nov 10, 2026
…olerant-reads

# Conflicts:
#	dart/a2ui_flutter/CHANGELOG.md
@polina-c

Copy link
Copy Markdown
Collaborator

From triage bot:

Triage suggestion:

For humans

Summary:
At the team's request on #2872, the PR adds the inputs that crashed genui catalog widgets as tests on the v0.9 and v1.0 basic catalogs of a2ui_flutter. None of them crash a2ui_flutter. It also fixes one crash the author found nearby: a Slider now treats an infinite min or max as absent.

Why flagged for triage:
This external PR has no assignee.

Suggestion:
Review the PR and assign yjbanov, who asked the author to move these tests to a2ui_flutter. polina-c said when closing #2872 that the team would review this PR separately. Most of the 576 added lines are tests, and the library change is a few lines in slider.dart with its own test, so the team can maintain it. It overlaps with #3411 by the same author: both change slider.dart (different lines) and add the same ## Unreleased heading to the changelog, so the second one to land needs a rebase. andrewkolos is reviewing #3411 and could review both instead. GitHub reports a merge conflict with main.

  1. Add labels: component: flutter adapter, lang: dart
  2. Assign: yjbanov
  3. Related issues: [BUG]: a schema-valid component can crash the surface it renders on #2872
  4. Related PRs: fix(a2ui_flutter): name the slider by its label #3411

To adjust and apply this suggestion, run in your a2ui checkout:

tools/internal/triage_new/triage_ui.sh https://github.com/a2ui-project/a2ui/pull/4108
For software
<a2ui>
root = TriageSuggestion(
  summary="""At the team's request on #2872, the PR adds the inputs that crashed `genui` catalog widgets as tests on the v0.9 and v1.0 basic catalogs of `a2ui_flutter`. None of them crash `a2ui_flutter`. It also fixes one crash the author found nearby: a `Slider` now treats an infinite `min` or `max` as absent.""",
  reason="""This external PR has no assignee.""",
  suggestion="""Review the PR and assign `yjbanov`, who [asked](https://github.com/a2ui-project/a2ui/issues/2872#issuecomment-6507250714) the author to move these tests to `a2ui_flutter`. `polina-c` [said](https://github.com/a2ui-project/a2ui/issues/2872#issuecomment-6808956224) when closing #2872 that the team would review this PR separately. Most of the 576 added lines are tests, and the library change is a few lines in [slider.dart](https://github.com/a2ui-project/a2ui/blob/8bf644a37d680a227296b8c0849a7f4b328b8b73/dart/a2ui_flutter/lib/src/catalog/basic/slider.dart) with its own test, so the team can maintain it. It overlaps with #3411 by the same author: both change `slider.dart` (different lines) and add the same `## Unreleased` heading to the changelog, so the second one to land needs a rebase. `andrewkolos` is reviewing #3411 and could review both instead. GitHub reports a merge conflict with `main`.""",
  added_labels=["component: flutter adapter", "lang: dart"],
  new_assignees=["yjbanov"],
  related_issues=[2872],
  related_prs=[3411]
)
</a2ui>

🤖 Agent-generated

This branch has not been deployed

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

Labels

status: needs-triage auto-managed: https://github.com/a2ui-project/a2ui/blob/main/scripts/triage.mjs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants