a2ui-project / a2ui-project/a2ui

Improve validateCatalogItemExamples to make sure the examples can be parsed.

Ouverte Adaptée aux débutants
#1,834 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
component: genui P3
Langage dominant
TypeScript
Étoiles
16.4k
Forks
1.3k
Merge moyen
2 j 13 h
PR mergées (30 j)
134

Description

_↴ Ported from [flutter/genui#449](https://github.com/flutter/genui/issues/449) — originally opened by [polina-c](https://github.com/polina-c) on 2025-10-26._
_Original labels: P3, c: ebb_

---

This is follow up for https://github.com/flutter/genui/pull/429

I was updating catalog items examples in my app to match new GenUi schema.

I updated the catalog items examples to look similar to those in genui and to pass this test:

```
for (final item in namedCatalog.catalog.items) {
test('CatalogItem ${item.name} examples are valid', () async {
if (item.name != 'code') return;
final errors = await validateCatalogItemExamples(
item,
namedCatalog.catalog,
);
expect(errors, isEmpty, reason: errors.join('\n'));
});
}
```

Tests passed, but the rendering failed:

Image

```
The following ArgumentError was thrown building AppCatalogView:
Invalid argument(s): Component.fromJson: component property is null

...

new Component.fromJson (package:flutter_genui/src/model/ui_models.dart:141:7)
```

After investigation I found i did not replace 'widget' with 'component' in one of items.

`validateCatalogItemExamples` should be updated to handle such errors, to make sure that DebugCatalogView can parse the items.

---

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

**[polina-c](https://github.com/polina-c)** commented on 2025-10-26:

@jacobsimionato

---

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

Removing from M1, because this isn't specific to that project.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Look at the validateCatalogItemExamples function, likely in a test or validation file. The function currently passes tests but does not catch JSON parsing errors like missing 'component' property. Update it to ensure examples can be parsed by Component.fromJson, possibly by adding a parsing step. Check the model file at package:flutter_genui/src/model/ui_models.dart:141 for the fromJson method to understand the expected structure. Run the existing test for catalog item examples to verify the fix.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
flutter, typescript
Domaine
testing, tooling
Type d'issue
Bug
Difficulté
2/5
Temps estimé
1-3 heures
Activité
Calme
Clarté
Clairement spécifiée
Accessibilité débutants
65/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.