a2ui-project / a2ui-project/a2ui

Improve error messages when attempting to convert unsupported schema features to Firebase AI Logic format

未关闭 适合新手
#1,830 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
component: genui P2
主要语言
TypeScript
星标
16.4k
派生
1.3k
平均合并
2 天 13 小时
30 天内合并 PR
134

描述

_↴ Ported from [flutter/genui#415](https://github.com/flutter/genui/issues/415) — originally opened by [juan-vgv](https://github.com/juan-vgv) on 2025-10-21._
_Original labels: P2_

---

**Describe the bug**

There seems to be an issue in which creating a component with `ListSchema` with `uniqueItems: true` will trigger the following warning:

`
[WARNING] 2025-10-21 15:03:22.543: Errors adapting parameters for tool surfaceUpdate: Error at path "#/properties/components/items/properties/component/properties/XXXX/properties/items": Unsupported keyword "uniqueItems". It will be ignored.
`

**To Reproduce**
Steps to reproduce the behavior:
1. Create a component with `ListSchema` and `uniqueItems: true`
2. Run the app

**Expected behavior**
No warning.

**Additional context**
Tested with `FirebaseAiClient` and latest commit from the repo beb5be5828f113cfde5dc738c9af16c2b3a07c52

---

### 2 comment(s) from the original issue

**[jacobsimionato](https://github.com/jacobsimionato)** commented on 2025-10-23:

Hi Juan!

Thanks for the report.

The underlying issue here is that the `json_schema_builder` library supports the full JSON specification, but Gemini (and other major LLM products) only support a subset of JSON schema features in structured output mode and function calling interfaces. There is some documentation of that here: https://ai.google.dev/gemini-api/docs/structured-output#json-schemas

We've chosen to build the Gen UI library on top of a generic JSON schema library rather than a limited one to make it easier to support the different and changing schema features of different models, and so that developers are free to use `json_schema_builder` as a generic schema library similar to `zod` in libraries which interop with Gen UI.

The error you're seeing is being thrown from the schema adapter at https://github.com/flutter/genui/blob/c369890604868e86d7b2e7b335789c7a6ceffba2/packages/flutter_genui_firebase_ai/lib/src/gemini_schema_adapter.dart#L372

Perhaps what we need here is an improved error message so that it's clear why this doesn't work? We'd love your suggestions!

---

**[juan-vgv](https://github.com/juan-vgv)** commented on 2025-10-27:

Ahhh, ok, I understand.

And yes, a more clear error message will definitely go a long way, but also maybe add a warning in the [json_schema_builder](https://github.com/flutter/genui/tree/main/packages/json_schema_builder) documentation with something like:

> Even though this library is JSON Schema 2020-12 compatible, most LLMs only take a subset, here's Gemini's...

Thanks!

贡献指南

打开贡献指南

调研方向

The issue points to the schema adapter at packages/flutter_genui_firebase_ai/lib/src/gemini_schema_adapter.dart line 372. Start by examining that file to understand how unsupported keywords like 'uniqueItems' are handled. The goal is to improve the error message to clarify the limitation (Gemini's subset of JSON Schema). Also consider adding a note to the json_schema_builder documentation. Check for existing tests around error messaging to ensure changes are consistent.

由索引模型根据 Issue 内容生成。

评估

技术栈
dart, firebase, typescript
领域
backend-api-design, documentation
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
冷清
描述清晰度
描述清楚
新手友好度
65/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。