RepoEdit via API fails with "repo is not a mirror, can not change mirror interval" #12975

Closed
opened 2025-11-02 10:26:46 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @PulsarFX on GitHub (May 9, 2024).

Description

When editing a repo with the GiteaAPI we get this error:

GiteaAPI.Client.ApiException
  HResult=0x80131500
  Message=Error calling RepoEdit: {"message":"repo is not a mirror, can not change mirror interval","url":"http://...:3000/api/swagger"}

  Source=GiteaAPI
  StackTrace:
   at GiteaAPI.Api.RepositoryApi.<RepoEditWithHttpInfoAsync>d__240.MoveNext()
   at GiteaAPI.Api.RepositoryApi.<RepoEditAsync>d__239.MoveNext()
   

when calling RepoEditAsync with some options and EditRepoOption { MirrorInterval=null } which should do nothing to the mirror interval, as stated in RepoEditAsync summary: "Edit a repository's properties. Only fields that are set will be changed"

This happens in 1.22-RC.1 and also 1.21.11 , but not in 1.21.1 (that's the versions we tested)

Gitea Version

1.22-RC.1

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?

  • windows go git,
  • linux gitea in docker

Database

SQLite

Originally created by @PulsarFX on GitHub (May 9, 2024). ### Description When editing a repo with the GiteaAPI we get this error: ``` GiteaAPI.Client.ApiException HResult=0x80131500 Message=Error calling RepoEdit: {"message":"repo is not a mirror, can not change mirror interval","url":"http://...:3000/api/swagger"} Source=GiteaAPI StackTrace: at GiteaAPI.Api.RepositoryApi.<RepoEditWithHttpInfoAsync>d__240.MoveNext() at GiteaAPI.Api.RepositoryApi.<RepoEditAsync>d__239.MoveNext() ``` when calling `RepoEditAsync` with some options and `EditRepoOption { MirrorInterval=null }` which should do nothing to the mirror interval, as stated in RepoEditAsync summary: "Edit a repository's properties. Only fields that are set will be changed" This happens in 1.22-RC.1 and also 1.21.11 , but not in 1.21.1 (that's the versions we tested) ### Gitea Version 1.22-RC.1 ### 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? - windows go git, - linux gitea in docker ### Database SQLite
GiteaMirror added the type/bug label 2025-11-02 10:26:46 -06:00
Author
Owner

@wxiaoguang commented on GitHub (May 9, 2024):

Regression: fix: update enable_prune even if mirror_interval is not provided (#28905) ?

@wxiaoguang commented on GitHub (May 9, 2024): Regression: fix: update enable_prune even if mirror_interval is not provided (#28905) ?
Author
Owner

@wxiaoguang commented on GitHub (May 9, 2024):

Have you set EnablePrune? It seems that EnablePrune is also for mirror only.

If neither MirrorInterval nor EnablePrune is set, then I guess API won't report the error?

@wxiaoguang commented on GitHub (May 9, 2024): Have you set `EnablePrune`? It seems that `EnablePrune` is also for mirror only. If neither MirrorInterval nor EnablePrune is set, then I guess API won't report the error?
Author
Owner

@PulsarFX commented on GitHub (May 9, 2024):

I have to dig some more. Hand crafted request via swagger Gui runs fine:

curl -X 'PATCH' \
  'http://localhost:3000/api/v1/repos/testdb/testdb' \
  -H 'accept: application/json' \
  -H 'authorization: Basic b.....z' \
  -H 'Content-Type: application/json' \
  -d '{
  "archived": false,
  "description": "repo description",
  "has_issues": false,
  "has_packages": true,
  "has_projects": false,
  "mirror_interval": null,
  "template": false
}'

Existing C# code, which is calling gitea via openApi generated c# client fails:

await _repositoryApi.RepoEditAsync(organizationName, organizationName, 
                 new EditRepoOption() { HasPullRequests = false });

This is the payload for this issue test:
grafik

@PulsarFX commented on GitHub (May 9, 2024): I have to dig some more. Hand crafted request via swagger Gui runs fine: ``` curl -X 'PATCH' \ 'http://localhost:3000/api/v1/repos/testdb/testdb' \ -H 'accept: application/json' \ -H 'authorization: Basic b.....z' \ -H 'Content-Type: application/json' \ -d '{ "archived": false, "description": "repo description", "has_issues": false, "has_packages": true, "has_projects": false, "mirror_interval": null, "template": false }' ``` Existing C# code, which is calling gitea via openApi generated c# client fails: ``` await _repositoryApi.RepoEditAsync(organizationName, organizationName, new EditRepoOption() { HasPullRequests = false }); ``` This is the payload for this issue test: ![grafik](https://github.com/go-gitea/gitea/assets/4960210/1298ff99-97cf-4f25-9065-dbea64daa9e6)
Author
Owner

@PulsarFX commented on GitHub (May 9, 2024):

quick check: openApi did not generate different code for class EditRepoOption between 1.21.3 and 1.21.11:

        /// <summary>
        /// set to a string like &#x60;8h30m0s&#x60; to set the mirror interval time
        /// </summary>
        /// <value>set to a string like &#x60;8h30m0s&#x60; to set the mirror interval time</value>
        [DataMember(Name = "mirror_interval", EmitDefaultValue = false)]
        public string MirrorInterval { get; set; }

Executing method RepositoryApi RepoEditWithHttpInfoAsync didn't change neither.

@PulsarFX commented on GitHub (May 9, 2024): quick check: openApi did not generate different code for class `EditRepoOption` between 1.21.3 and 1.21.11: ``` /// <summary> /// set to a string like &#x60;8h30m0s&#x60; to set the mirror interval time /// </summary> /// <value>set to a string like &#x60;8h30m0s&#x60; to set the mirror interval time</value> [DataMember(Name = "mirror_interval", EmitDefaultValue = false)] public string MirrorInterval { get; set; } ``` Executing method `RepositoryApi RepoEditWithHttpInfoAsync` didn't change neither.
Author
Owner

@wxiaoguang commented on GitHub (May 10, 2024):

Hmm yes, the problem is that EnablePrune = false makes the backend runs the "update mirror" logic ......

Maybe it could be fixed by fine-tuning the logic again.

@wxiaoguang commented on GitHub (May 10, 2024): Hmm yes, the problem is that `EnablePrune = false` makes the backend runs the "update mirror" logic ...... Maybe it could be fixed by fine-tuning the logic again.
Author
Owner

@PulsarFX commented on GitHub (May 13, 2024):

maybe make EnablePrune nullable, like public bool? EnablePrune {get; set;} ?
Both states are valid for calling the api. So, to not use it, a third state is required. In swagger, the property can simply be left out, but not in EditRepoOption as it is just of type bool.

@PulsarFX commented on GitHub (May 13, 2024): maybe make `EnablePrune` nullable, like `public bool? EnablePrune {get; set;}` ? Both states are valid for calling the api. So, to not use it, a third state is required. In swagger, the property can simply be left out, but not in `EditRepoOption` as it is just of type `bool`.
Author
Owner

@wxiaoguang commented on GitHub (May 13, 2024):

Actually, the EnablePrune has the same definition as MirrorInterval. Ideally the SDKs should know that EnablePrune is optional and shouldn't send it to server, no idea why the SDK still sends it.

	// set to a string like `8h30m0s` to set the mirror interval time
	MirrorInterval *string `json:"mirror_interval,omitempty"`
	// enable prune - remove obsolete remote-tracking references when mirroring
	EnablePrune *bool `json:"enable_prune,omitempty"`

I think we can do this on Gitea side: " Simplify mirror repository API logic #30963 " and have simpler code.

@wxiaoguang commented on GitHub (May 13, 2024): Actually, the `EnablePrune` has the same definition as `MirrorInterval`. Ideally the SDKs should know that EnablePrune is optional and shouldn't send it to server, no idea why the SDK still sends it. ``` // set to a string like `8h30m0s` to set the mirror interval time MirrorInterval *string `json:"mirror_interval,omitempty"` // enable prune - remove obsolete remote-tracking references when mirroring EnablePrune *bool `json:"enable_prune,omitempty"` ``` I think we can do this on Gitea side: " Simplify mirror repository API logic #30963 " and have simpler code.
Author
Owner

@wxiaoguang commented on GitHub (May 18, 2024):

1.22 nightly is ready, could you try it? https://dl.gitea.com/gitea/1.22/ or by docker "1.22-nightly"

@wxiaoguang commented on GitHub (May 18, 2024): 1.22 nightly is ready, could you try it? https://dl.gitea.com/gitea/1.22/ or by docker "1.22-nightly"
Author
Owner

@PulsarFX commented on GitHub (May 27, 2024):

works in the just released Gitea 1.22.
Thanks alot!

@PulsarFX commented on GitHub (May 27, 2024): works in the just released Gitea 1.22. Thanks alot!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#12975