Skip to content

fix: accept answer fails when short links enabled (#1541)#1544

Open
hgaol wants to merge 1 commit into
apache:devfrom
hgaol:1541
Open

fix: accept answer fails when short links enabled (#1541)#1544
hgaol wants to merge 1 commit into
apache:devfrom
hgaol:1541

Conversation

@hgaol

@hgaol hgaol commented Jun 9, 2026

Copy link
Copy Markdown
Member

Close #1541

The ownership check added to AcceptAnswer compared the answer's QuestionID against the request's QuestionID directly. When short links are enabled, answerRepo.GetByID re-encodes QuestionID to its short form while the controller de-shorts req.QuestionID to its long form, so the two encodings of the same question never matched and every accept returned "Answer do not found". Normalize both ids via uid.DeShortID before comparing, preserving the privilege-escalation guard for answers that truly belong to another question.

Validated in local environment.

The ownership check added to AcceptAnswer compared the answer's QuestionID
against the request's QuestionID directly. When short links are enabled,
answerRepo.GetByID re-encodes QuestionID to its short form while the
controller de-shorts req.QuestionID to its long form, so the two encodings
of the same question never matched and every accept returned "Answer do not
found". Normalize both ids via uid.DeShortID before comparing, preserving the
privilege-escalation guard for answers that truly belong to another question.
@LinkinStars LinkinStars self-assigned this Jun 10, 2026
@LinkinStars LinkinStars added this to the v2.0.2 milestone Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants