You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug][GitHub] A short token causes a panic, and then the connection list returns 500 #9446
I had searched in the issues and found no similar issues.
What happened
When a GitHub token has a known prefix but is too short, saving the connection causes a panic.
Cause:
sanitizeToken in backend/plugins/github/models/connection.go checks only tokenLen >= prefixLen (line 334).
Then it reads token[prefixLen+showPrefixLen : prefixLen+showPrefixLen+hiddenLen] (line 336).
This index is out of range when a classic token (ghp_, gho_, ghs_, ghr_, ghu_) has fewer than 32 characters, or when a github_pat_ token has fewer than 85 characters.
ModelApiHelper.Post saves the row (model_api_helper.go:72) before it calls Sanitize (line 76). So the connection is saved, even though the request fails.
Every later read calls Sanitize on this row and panics. GET /plugins/github/connections returns 500 for all GitHub connections until the row is deleted.
What do you expect to happen
A token that is too short is rejected with a clear error, or it is masked without a panic.
When the request fails, nothing is saved.
One bad connection does not stop the connection list from loading.
How to reproduce
Tested with the image apache/devlake:main_261124_0230_52d63a1 and MySQL 8.4.
Send POST /plugins/github/connections with {"name":"short","endpoint":"https://api.github.com/","authMethod":"AccessToken","token":"ghp_short"}. Result: 500. The log shows panic recovered: runtime error: slice bounds out of range [:32] with length 9 at connection.go:336.
The row is in the _tool_github_connections table.
Send GET /plugins/github/connections. Result: 500, with the same panic. This also happens when a valid connection exists. GET /plugins/github/connections/<valid id> returns 200.
Send DELETE /plugins/github/connections/<short id>. The row is deleted, but the result is 500. After this, the list returns 200 again.
A github_pat_ token with 30 characters gives the same result.
Anything else
It happens every time. A user can cause it by copying only part of a token. After that, the GitHub connections page does not load.
Possible fix: check tokenLen >= prefixLen+showPrefixLen+hiddenLen before the slice.
changed the title [-][Bug][GitHub] A short token panics on save, and the saved connection then breaks the connections list[/-][+][Bug][GitHub] A short token causes a panic, and then the connection list returns 500[/+]on Nov 25, 2026
Activity
[-][Bug][GitHub] A short token panics on save, and the saved connection then breaks the connections list[/-][+][Bug][GitHub] A short token causes a panic, and then the connection list returns 500[/+]fix(github): mask a short token without a panic