Maximum topic lengths in model definition and validation differ #6210

Closed
opened 2025-11-02 06:48:30 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @shiftinv on GitHub (Oct 24, 2020).

  • Gitea version (or commit ref): 1.13.0+rc1
  • Git version: 2.26.2
  • Operating system: Docker on Ubuntu 18.04
  • Database:
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No

Description

The ValidateTopic method in models/topic.go as well as the UI specify a maximum length of 35 characters for topics:
c5020cff3d/models/topic.go (L58-L60) c5020cff3d/options/locale/locale_en-US.ini (L1855)

The Topic model's Name column however is specified to have a maximum of 25 characters:
c5020cff3d/models/topic.go (L29)


Because of this, assigning a topic with 26-35 characters to a repository fails with this error:

...outers/repo/topic.go:50:TopicsPost() [E] SaveTopics failed: Error 1406: Data too long for column 'name' at row 1

Trying to migrate a repository from GitHub with topics that are within GitHub's limit of 35 characters but longer than 25 characters (e.g. https://github.com/vtil-project/VTIL-Core) fails with a similar error:

...ules/task/migrate.go:64:func1() [E] DeleteRepository: repository does not exist [id: 40, uid: 1, owner_name: , name: ]
modules/task/task.go:51:handle() [E] Run task failed: Error 1406: Data too long for column 'name' at row 1

I assume that it isn't reproducible on try.gitea.io because it uses SQLite, which would treat VARCHAR like TEXT and therefore would not enforce the specified maximum length.

Originally created by @shiftinv on GitHub (Oct 24, 2020). - Gitea version (or commit ref): `1.13.0+rc1` - Git version: `2.26.2` - Operating system: `Docker on Ubuntu 18.04` - Database: - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [x] No ## Description The `ValidateTopic` method in `models/topic.go` as well as the UI specify a maximum length of 35 characters for topics: https://github.com/go-gitea/gitea/blob/c5020cff3df0a7d77ff7a453a2007edc7e5c3667/models/topic.go#L58-L60 https://github.com/go-gitea/gitea/blob/c5020cff3df0a7d77ff7a453a2007edc7e5c3667/options/locale/locale_en-US.ini#L1855 The `Topic` model's `Name` column however is specified to have a maximum of 25 characters: https://github.com/go-gitea/gitea/blob/c5020cff3df0a7d77ff7a453a2007edc7e5c3667/models/topic.go#L29 <br/> Because of this, assigning a topic with 26-35 characters to a repository fails with this error: ``` ...outers/repo/topic.go:50:TopicsPost() [E] SaveTopics failed: Error 1406: Data too long for column 'name' at row 1 ``` Trying to migrate a repository from GitHub with topics that are within GitHub's limit of 35 characters but longer than 25 characters (e.g. https://github.com/vtil-project/VTIL-Core) fails with a similar error: ``` ...ules/task/migrate.go:64:func1() [E] DeleteRepository: repository does not exist [id: 40, uid: 1, owner_name: , name: ] modules/task/task.go:51:handle() [E] Run task failed: Error 1406: Data too long for column 'name' at row 1 ``` I assume that it isn't reproducible on try.gitea.io because it uses SQLite, which would treat `VARCHAR` like `TEXT` and therefore would not enforce the specified maximum length.
GiteaMirror added the issue/staletype/bug labels 2025-11-02 06:48:30 -06:00
Author
Owner

@lunny commented on GitHub (Oct 25, 2020):

We should alter the column to 35

@lunny commented on GitHub (Oct 25, 2020): We should alter the column to 35
Author
Owner

@stale[bot] commented on GitHub (Dec 26, 2020):

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale[bot] commented on GitHub (Dec 26, 2020): This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
Author
Owner

@lunny commented on GitHub (Dec 26, 2020):

duplicated with #14108

@lunny commented on GitHub (Dec 26, 2020): duplicated with #14108
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6210