tag_metadata#231
Conversation
Confidence Score: 3/5Merging carries a real risk of data loss for any tag created before this change — opening and saving such a tag in the edit dialog will submit empty metadata instead of preserving the existing name and description. The edit-form fallback for legacy tags initialises all language fields to empty strings rather than seeding them from tag.name and tag.description. Any user who opens and saves one of those older tags will silently overwrite valid data with an empty payload. src/components/routes/tags/TagFormDialog.tsx — the else branch in the useEffect that populates form state when tag.metadata is empty. Reviews (1): Last reviewed commit: "tag_metadata" | Re-trigger Greptile |
| } else { | ||
| setActiveLanguages(["EN"]); | ||
| setLanguageData({ | ||
| EN: { name: "", description: "" }, | ||
| BO: { name: "", description: "" }, | ||
| ZH: { name: "", description: "" }, | ||
| }); | ||
| } |
There was a problem hiding this comment.
Edit form shows blank fields for legacy tags
When opening the edit dialog for a tag that was created before the metadata migration — where tag.metadata is empty but tag.name and tag.description still hold valid data — the else branch resets all language inputs to empty strings. A user editing such a tag would see a blank form, and submitting it would overwrite the existing name/description with empty metadata. The fallback should seed the EN block from tag.name and tag.description.
| } else { | |
| setActiveLanguages(["EN"]); | |
| setLanguageData({ | |
| EN: { name: "", description: "" }, | |
| BO: { name: "", description: "" }, | |
| ZH: { name: "", description: "" }, | |
| }); | |
| } | |
| } else { | |
| setActiveLanguages(["EN"]); | |
| setLanguageData({ | |
| EN: { name: tag?.name ?? "", description: tag?.description ?? "" }, | |
| BO: { name: "", description: "" }, | |
| ZH: { name: "", description: "" }, | |
| }); | |
| } |
| interface LanguageData { | ||
| name: string; | ||
| description: string; | ||
| } |
There was a problem hiding this comment.
Duplicated
LanguageData interface
An identical LanguageData interface is declared in both this file and TagFormDialog.tsx. Keeping two copies means future changes to the shape must be made in both places. Consider extracting it alongside TagMetadataInput in tagsApi.ts (or a shared types file) so both components import the same definition.
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!
No description provided.