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
After fix for maven packages in 33678, when trying to GET maven-metadata.xml for a non-existent package, function serveMavenMetadata crashes with an index out of range [-1] panic as no Maven package versions are found. I suppose this happens because the function attempts to access pds[len(pds)-1], but pds is empty.
Steps to Reproduce
Ensure no package versions exist for the given GroupID:ArtifactID.
Attempt to curl GET com/group/id/artifactId/maven-metadata.xml for the non-existent package.
Get 500 response and see the log with index out of range [-1] panic.
Expected Behavior
The function should return more clear HTTP response (e.g., 404 Not Found) instead of panicking.
Backport #33888 by @wxiaoguangFix#33886
Restore the old logic from #16510, which was incorrectly removed by
#33678
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Description
After fix for maven packages in 33678, when trying to GET maven-metadata.xml for a non-existent package, function
serveMavenMetadata
crashes with anindex out of range [-1]
panic as no Maven package versions are found. I suppose this happens because the function attempts to accesspds[len(pds)-1]
, butpds
is empty.Steps to Reproduce
GroupID:ArtifactID
.com/group/id/artifactId/maven-metadata.xml
for the non-existent package.index out of range [-1]
panic.Expected Behavior
The function should return more clear HTTP response (e.g.,
404 Not Found
) instead of panicking.Where I think the problem is
routers/api/packages/maven/maven.go
func serveMavenMetadata
Suggested Fix
Add a check for package versions found before continuing:
Environment
Gitea Version
1.23.5
Can you reproduce the bug on the Gitea demo site?
Yes
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
Locally
Database
None
The text was updated successfully, but these errors were encountered: