Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dianaStr7 opened this issue Feb 21, 2025 · 4 comments · Fixed by #33678
Labels

Comments

@dianaStr7
Copy link
Contributor

dianaStr7 commented 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

@dianaStr7 dianaStr7 changed the title GET Request for Maven Packages - maven-metadata.xml Returns 'Package Does Not Exist' for Existing GET Request for Maven Package maven-metadata.xml Returns 'Package Does Not Exist' after update Feb 21, 2025
@dianaStr7 dianaStr7 changed the title GET Request for Maven Package maven-metadata.xml Returns 'Package Does Not Exist' after update GET Request for Maven Package maven-metadata.xml Returns 'Package Does Not Exist' after update to 1.23 Feb 21, 2025
@wxiaoguang
Copy link
Contributor

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?

@dianaStr7
Copy link
Contributor Author

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.

@wxiaoguang
Copy link
Contributor

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants