Skip to content

Fix CRAN package version validation to allow more than 4 version components#36813

Merged
wxiaoguang merged 2 commits intomainfrom
copilot/fix-upload-r-packages
Mar 3, 2026
Merged

Fix CRAN package version validation to allow more than 4 version components#36813
wxiaoguang merged 2 commits intomainfrom
copilot/fix-upload-r-packages

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 3, 2026

R packages like RcppEigen use versions with 5+ components (e.g., 0.3.4.0.2), which were rejected with "package version is invalid" due to an overly restrictive regex.

R's numeric_version spec imposes no upper bound on version components, so the {1,3} quantifier (limiting to 4 total components) was incorrect.

Changes

  • modules/packages/cran/metadata.go: Relax version regex from {1,3} to +, accepting any number of dot/dash-separated integer components ≥ 2:
    - versionPattern = regexp.MustCompile(`\A[0-9]+(?:[.\-][0-9]+){1,3}\z`)
    + versionPattern = regexp.MustCompile(`\A[0-9]+(?:[.\-][0-9]+)+\z`)
  • modules/packages/cran/metadata_test.go: Remove 1.2.3.4.5 / 1-2-3-4-5 from the invalid-version list; add ValidVersionManyComponents test covering 0.3.4.0.2, 1.2.3.4.5, and 1-2-3-4-5.
Original prompt

This section details on the original issue you should resolve

<issue_title>Problem upload R Packages into Gitea CRAN repo</issue_title>
<issue_description>### Description

When trying to upload a R package downloaded from the official CRAN repository :

https://cran.r-project.org/web/packages/RcppEigen/index.html

with the official curl method presented on the Gitea official website :

curl --user [user]:[password] --upload-file ./Packages/RcppEigen/RcppEigen_0.3.4.0.2.tar.gz [my_gitea_instance]/api/packages/[organization]/cran/src

it leads to the following error :

package version is invalid400

For many other packages, it works perfectly.

Gitea Version

1.22.4

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

package version is invalid400

Screenshots

No response

Git Version

No response

Operating System

Ubuntu 22.04.1 LTS

How are you running Gitea?

I have a managed Gitea instance deployed on a VM Ubuntu 22.04.1 LTS with snap method
I try to import the package from the same VM where my Gitea instance is deployed

Database

None</issue_description>

<agent_instructions>Open a PR by the suggested fix and add a test for this case.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 3, 2026
Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with uploading R packages to Gitea CRAN repo Fix CRAN package version validation to allow more than 4 version components Mar 3, 2026
@wxiaoguang wxiaoguang marked this pull request as ready for review March 3, 2026 11:32
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Mar 3, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 3, 2026
@wxiaoguang wxiaoguang added the backport/v1.25 This PR should be backported to Gitea 1.25 label Mar 3, 2026
@wxiaoguang wxiaoguang added this to the 1.26.0 milestone Mar 3, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 3, 2026
@wxiaoguang wxiaoguang merged commit 93e3be3 into main Mar 3, 2026
43 of 44 checks passed
@wxiaoguang wxiaoguang deleted the copilot/fix-upload-r-packages branch March 3, 2026 17:56
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Mar 3, 2026
…onents (go-gitea#36813)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Mar 3, 2026
wxiaoguang added a commit that referenced this pull request Mar 4, 2026
…onents (#36813) (#36821)

Backport #36813

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 4, 2026
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  fix: /repos/{owner}/{repo}/actions/{runs,jobs} requiring owner permissions (go-gitea#36818)
  Fix CRAN package version validation to allow more than 4 version components (go-gitea#36813)
  Fix API not persisting pull request unit config when has_pull_requests is not set (go-gitea#36718)
  feat: Add Actions API rerun endpoints for runs and jobs (go-gitea#36768)
  Fix bug when pushing mirror with wiki (go-gitea#36795)
  Pull Request Pusher should be the author of the merge (go-gitea#36581)
  Delete non-exist branch should return 404 (go-gitea#36694)
  Remove API registration-token (go-gitea#36801)
  Add background and run count to actions list page (go-gitea#36707)
silverwind added a commit to silverwind/gitea that referenced this pull request Mar 6, 2026
* origin/main: (27 commits)
  Fix OAuth2 authorization code expiry and reuse handling (go-gitea#36797)
  Fix org permission API visibility checks for hidden members and private orgs (go-gitea#36798)
  Fix non-admins unable to automerge PRs from forks (go-gitea#36833)
  upgrade to github.com/cloudflare/circl 1.6.3, svgo 4.0.1, markdownlint-cli 0.48.0 (go-gitea#36837)
  Fix dump release asset bug (go-gitea#36799)
  build(deps): update material-icon-theme v5.32.0 (go-gitea#36832)
  Fix bug to check whether user can update pull request branch or rebase branch (go-gitea#36465)
  Fix forwarded proto handling for public URL detection (go-gitea#36810)
  Fix artifacts v4 backend upload problems (go-gitea#36805)
  Add a git grep search timeout (go-gitea#36809)
  fix(repo): unify DEFAULT_SHOW_FULL_NAME output in templates and dropdown (go-gitea#36597)
  Harden render iframe open-link handling (go-gitea#36811)
  [skip ci] Updated translations via Crowdin
  fix: /repos/{owner}/{repo}/actions/{runs,jobs} requiring owner permissions (go-gitea#36818)
  Fix CRAN package version validation to allow more than 4 version components (go-gitea#36813)
  Fix API not persisting pull request unit config when has_pull_requests is not set (go-gitea#36718)
  feat: Add Actions API rerun endpoints for runs and jobs (go-gitea#36768)
  Fix bug when pushing mirror with wiki (go-gitea#36795)
  Pull Request Pusher should be the author of the merge (go-gitea#36581)
  Delete non-exist branch should return 404 (go-gitea#36694)
  ...

# Conflicts:
#	routers/web/repo/issue_view.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/done All backports for this PR have been created backport/v1.25 This PR should be backported to Gitea 1.25 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem upload R Packages into Gitea CRAN repo

4 participants