GET Request for Maven Package maven-metadata.xml Returns 'Package Does Not Exist' after update to 1.23 #14167

Closed
opened 2025-11-02 11:05:05 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @dianaStr7 on GitHub (Feb 21, 2025).

Description

Description

After updating Gitea from version 1.22 to 1.23, we encountered an issue where newly rebuilt Maven packages maven-metadata.xml is accessible via GET request, but older packages return a 404 error package does not exist.

Steps to Reproduce

Upgrade Gitea from version 1.22 to 1.23.

Attempt to fetch an existing Maven package maven-metadata.xml using the API:

   curl -X "GET" -H "Authorization: token <token>" -H "Content-Type: application/json"
   http://<gitea-instance>/api/packages/{owner}/maven/com/example/project/maven-metadata.xml

Observe that older packages return a "package does not exist", while data for newly rebuilt packages is accessible (this is one way to solve it, rebuild the older package so then the name will change to the new convention).

Expected Behavior

Older Maven packages maven-metadata.xml should remain accessible via the API after upgrading Gitea.

Actual Behavior

Packages stored with the previous naming convention (groupId-artifactId) are no longer accessible. The database now stores package names in the format groupId:artifactId, and queries only resolve to this new format, ignoring existing packages using the old format.

Database Logs Analysis

Queries are resolving only to the groupId:artifactId format.
Existing packages using the groupId-artifactId format are not matched, leading to 404 errors.

Environment

Gitea version: 1.23.3
Previous version: 1.22.2
Database: PostgreSQL
OS: Linux
Deployment: Docker

Possible Fix

The source code suggests that older packages should also be resolved, but there seems to be a bug preventing this from happening.

Gitea Version

1.23.3

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

We are running Gitea self-hosted on Rancher in a Kubernetes pod with Linux.

Database

PostgreSQL

Originally created by @dianaStr7 on GitHub (Feb 21, 2025). ### Description ## Description After updating Gitea from version 1.22 to 1.23, we encountered an issue where newly rebuilt Maven packages maven-metadata.xml is accessible via GET request, but older packages return a 404 error package does not exist. ## Steps to Reproduce Upgrade Gitea from version 1.22 to 1.23. Attempt to fetch an existing Maven package maven-metadata.xml using the API: curl -X "GET" -H "Authorization: token <token>" -H "Content-Type: application/json" http://<gitea-instance>/api/packages/{owner}/maven/com/example/project/maven-metadata.xml Observe that older packages return a "package does not exist", while data for newly rebuilt packages is accessible (this is one way to solve it, rebuild the older package so then the name will change to the new convention). ## Expected Behavior Older Maven packages maven-metadata.xml should remain accessible via the API after upgrading Gitea. ## Actual Behavior Packages stored with the previous naming convention (groupId-artifactId) are no longer accessible. The database now stores package names in the format groupId:artifactId, and queries only resolve to this new format, ignoring existing packages using the old format. ## Database Logs Analysis Queries are resolving only to the groupId:artifactId format. Existing packages using the groupId-artifactId format are not matched, leading to 404 errors. ## Environment Gitea version: 1.23.3 Previous version: 1.22.2 Database: PostgreSQL OS: Linux Deployment: Docker ## Possible Fix The source code suggests that older packages should also be resolved, but there seems to be a bug preventing this from happening. ### Gitea Version 1.23.3 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? We are running Gitea self-hosted on Rancher in a Kubernetes pod with Linux. ### Database PostgreSQL
GiteaMirror added the type/bug label 2025-11-02 11:05:05 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Feb 21, 2025):

I think it's related to https://github.com/go-gitea/gitea/pull/33049

There are some fallback mechanisms and some tests (try groupId-artifactId then groupId:artifactId), are there still some edge cases?

@wxiaoguang commented on GitHub (Feb 21, 2025): I think it's related to https://github.com/go-gitea/gitea/pull/33049 There are some fallback mechanisms and some tests (try `groupId-artifactId` then `groupId:artifactId`), are there still some edge cases?
Author
Owner

@dianaStr7 commented on GitHub (Feb 21, 2025):

I think it's related to #33049

There are some fallback mechanisms and some tests (try groupId-artifactId then groupId:artifactId), are there still some edge cases?

Yes, I tried it locally and it see that the call back is never executed because the part

if errors.Is(err, util.ErrNotExist) {
		pvs, err = packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeMaven, params.toInternalPackageNameLegacy())
	}

seems to be never called as util.ErrNotExis is not thrown. I have a fix and can open a pull request for it.

@dianaStr7 commented on GitHub (Feb 21, 2025): > I think it's related to [#33049](https://github.com/go-gitea/gitea/pull/33049) > > There are some fallback mechanisms and some tests (try `groupId-artifactId` then `groupId:artifactId`), are there still some edge cases? Yes, I tried it locally and it see that the call back is never executed because the part ```go if errors.Is(err, util.ErrNotExist) { pvs, err = packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeMaven, params.toInternalPackageNameLegacy()) } ``` seems to be never called as util.ErrNotExis is not thrown. I have a fix and can open a pull request for it.
Author
Owner

@wxiaoguang commented on GitHub (Feb 21, 2025):

seems to be never called as util.ErrNotExis is not thrown. I have a fix and can open a pull request for it.

Thank you very much!

@wxiaoguang commented on GitHub (Feb 21, 2025): > seems to be never called as util.ErrNotExis is not thrown. I have a fix and can open a pull request for it. Thank you very much!
Author
Owner

@wxiaoguang commented on GitHub (Feb 22, 2025):

1.23-nightly is ready (it is a stable release and will be 1.23.5)

@wxiaoguang commented on GitHub (Feb 22, 2025): 1.23-nightly is ready (it is a stable release and will be 1.23.5) * https://dl.gitea.com/gitea/1.23-nightly/ * https://hub.docker.com/r/gitea/gitea/tags?name=1.23-nightly
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14167