Skip to content

Fix scalar tags splitting into single-character list in card front matter - #5017

Merged
Wauplin merged 4 commits into
huggingface:mainfrom
zeenat28-ui:fix-scalar-tags-repocard
Sep 28, 2026
Merged

Wauplin merged 4 commits into
huggingface:mainfrom
zeenat28-ui:fix-scalar-tags-repocard

Conversation

@zeenat28-ui

@zeenat28-ui zeenat28-ui commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5012
Loading a ModelCard or SpaceCard with a scalar string in front matter (e.g. tags: text-classification) silently shredded the tag into individual characters (['t', 'e', 'x', ...]). Because Python strings are iterable, _to_unique_list iterated character-by-character instead of treating the value as a single tag.

This normalizes tags to [tags] if a string is provided, matching how sibling fields like language and datasets handle scalar inputs. Also updates the type annotations on ModelCardData and SpaceCardData to reflect str | list[str] | None.

Added regression tests in test_repocard_data.py and test_repocard.py.

Who can review?
@@Wauplin


Note

Low Risk
Small, localized metadata normalization change with no auth, network, or persistence logic beyond correct tag parsing.

Overview
Fixes a bug where scalar tags in README front matter (e.g. tags: text-classification) were turned into one-character entries because _to_unique_list iterated the string directly.

_to_unique_list now wraps a str in a one-element list before deduplication, consistent with how other card fields accept scalars. ModelCardData and SpaceCardData both route tags through this helper, so loading and constructing cards preserves the full tag string.

Reviewed by Cursor Bugbot for commit 399a1c6. Bugbot is set up for automated code reviews on this repo. Configure here.

…tter

Fixes huggingface#5012

Signed-off-by: zeenat28-ui <zeenatriaz468@gmail.com>
Signed-off-by: zeenat28-ui <zeenatriaz468@gmail.com>
…ontent

Signed-off-by: zeenat28-ui <zeenatriaz468@gmail.com>
@bot-ci-comment

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Wauplin Wauplin 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.

Thanks for reporting and fixing!

@Wauplin
Wauplin merged commit 41222c5 into huggingface:main Sep 28, 2026
13 of 21 checks passed
@huggingface-hub-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v2.1.0 release.

@zeenat28-ui
zeenat28-ui deleted the fix-scalar-tags-repocard branch October 17, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A scalar tags value in a card's front matter is split into one-letter tags and written back

2 participants