Skip to content

fix(repo): prevent double-write redirect collisions on dependency errors, fix ui - #38627

Merged
wxiaoguang merged 5 commits into
go-gitea:mainfrom
SudhanshuMatrix:fix/dependency-redirect-collision
Jul 25, 2026
Merged

wxiaoguang merged 5 commits into
go-gitea:mainfrom
SudhanshuMatrix:fix/dependency-redirect-collision

Conversation

@SudhanshuMatrix

@SudhanshuMatrix SudhanshuMatrix commented Jul 25, 2026 •

Copy link
Copy Markdown
Member
  1. fix AddDependency and RemoveDependency to respond correctly
  2. refactor the form to use "form-fetch-action"
  3. fix the issue dependency icon layout regression

Prevent double-write response header collisions in the issue
dependency handler (AddDependency) by checking if a response
has already been written before executing the deferred redirect.

Signed-off-by: Sudhanshu Singh <sudhanshuwriterblc@gmail.com>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 25, 2026
@github-actions github-actions Bot added topic/repo Related to repositories type/bug labels Jul 25, 2026
@wxiaoguang

Copy link
Copy Markdown
Contributor

Thank you very much for catching the bug.

Using "defer" in route handler indeed is bad (see the horrible "defer" in NewComment, which was fixed by "Fix various problems (#37077)")

So, I think we should refactor the code to be more straightforward: clearly respond what it should do.

@wxiaoguang

wxiaoguang commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

And the rule is: if you found one cockroach in a room, then there must be not just only one in the room.

So I took a look at the related code, it is also wrong in RemoveDependency 🤣 , just more bugs:

Details image

…citly

Refactor AddDependency and RemoveDependency in issue_dependency.go
to call ctx.Redirect explicitly on success and user/validation error
paths. This removes the implicit defer block in AddDependency, resolving
both response header write collisions on server errors and response hangs
on RemoveDependency errors.

Signed-off-by: Sudhanshu Singh <sudhanshuwriterblc@gmail.com>
@wxiaoguang

Copy link
Copy Markdown
Contributor

Will try to refactor the HTML part to use "form-fetch-action", just a moment.

@wxiaoguang

wxiaoguang commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Also found a UI regression, fixed together (I will create a separate backport PR for 1.27)

Before:

Details image

After:

Details image

Backport:

@wxiaoguang wxiaoguang added backport/done All backports for this PR have been created backport/manual No power to the bots! Create your backport yourself! backport/v1.27 This PR should be backported to Gitea 1.27 labels Jul 25, 2026
@wxiaoguang wxiaoguang changed the title fix(repo): prevent double-write redirect collisions on dependency errors fix(repo): prevent double-write redirect collisions on dependency errors, fix ui Jul 25, 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 Jul 25, 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 Jul 25, 2026
@wxiaoguang
wxiaoguang merged commit fadaf36 into go-gitea:main Jul 25, 2026
26 checks passed
@GiteaBot GiteaBot added this to the 28.0.0 milestone Jul 25, 2026
wxiaoguang added a commit that referenced this pull request Jul 25, 2026
…ors, fix ui (#38627) (#38628)

Backport #38627

Co-authored-by: Sudhanshu Singh <sudhanshuwriterblc@gmail.com>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jul 27, 2026
* 'main' of https://github.com/go-gitea/gitea: (55 commits)
  fix(actions): use base branch ref for pull_request_target context (go-gitea#38636)
  fix(actions): skip already-approved runs in `ApproveRuns` (go-gitea#38653)
  fix(api): accept fully-qualified refs in contents API (go-gitea#38650)
  [skip ci] Updated translations via Crowdin
  chore(build): upload release to Cloudflare R2 (go-gitea#38635)
  ci: match `# renovate:` markers that trail the value (go-gitea#38640)
  feat: admin impersonates a user (go-gitea#38614)
  refactor: git patch apply (go-gitea#38637)
  fix: orgmode render include path (go-gitea#38642)
  fix(actions): cancel tasks immediately when the runner stopped reporting (go-gitea#38616)
  fix(issues): fix label bulk-load key and reduce log noise in LoadLabel (go-gitea#38632)
  fix(ui): avoid layout shifts in `overflow-menu` and repo filter (go-gitea#37818)
  chore: generate codemirror languages from `linguist-languages` package (go-gitea#38624)
  [skip ci] Updated translations via Crowdin
  fix(actions): improve runner list status sorting, labels and task job links (go-gitea#38586)
  fix(actions): correctness and hardening fixes (go-gitea#38518)
  chore: remove goreportcard badge (go-gitea#38630)
  fix(repo): prevent double-write redirect collisions on dependency errors, fix ui (go-gitea#38627)
  fix(deps): update module github.com/getkin/kin-openapi to v0.144.0 [security] (go-gitea#38623)
  chore: update and relax revive naming rules (go-gitea#38615)
  ...
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jul 27, 2026
* main: (55 commits)
  fix(actions): use base branch ref for pull_request_target context (go-gitea#38636)
  fix(actions): skip already-approved runs in `ApproveRuns` (go-gitea#38653)
  fix(api): accept fully-qualified refs in contents API (go-gitea#38650)
  [skip ci] Updated translations via Crowdin
  chore(build): upload release to Cloudflare R2 (go-gitea#38635)
  ci: match `# renovate:` markers that trail the value (go-gitea#38640)
  feat: admin impersonates a user (go-gitea#38614)
  refactor: git patch apply (go-gitea#38637)
  fix: orgmode render include path (go-gitea#38642)
  fix(actions): cancel tasks immediately when the runner stopped reporting (go-gitea#38616)
  fix(issues): fix label bulk-load key and reduce log noise in LoadLabel (go-gitea#38632)
  fix(ui): avoid layout shifts in `overflow-menu` and repo filter (go-gitea#37818)
  chore: generate codemirror languages from `linguist-languages` package (go-gitea#38624)
  [skip ci] Updated translations via Crowdin
  fix(actions): improve runner list status sorting, labels and task job links (go-gitea#38586)
  fix(actions): correctness and hardening fixes (go-gitea#38518)
  chore: remove goreportcard badge (go-gitea#38630)
  fix(repo): prevent double-write redirect collisions on dependency errors, fix ui (go-gitea#38627)
  fix(deps): update module github.com/getkin/kin-openapi to v0.144.0 [security] (go-gitea#38623)
  chore: update and relax revive naming rules (go-gitea#38615)
  ...
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Oct 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport/done All backports for this PR have been created backport/manual No power to the bots! Create your backport yourself! backport/v1.27 This PR should be backported to Gitea 1.27 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/repo Related to repositories type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

⌂