fix(api): default same-repo issue dependencies to current repo #23
Reference in New Issue
Block a user
Delete Branch "fix/issue-22-dependencies-api-same-repo"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
The issue dependencies/blocks POST and DELETE API handlers (
/repos/{owner}/{repo}/issues/{index}/dependenciesand.../blocks) 500'd whenever the request body omittedowner/repo— i.e. for a same-repo dependency.Root cause
getFormIssueinrouters/api/v1/repo/issue_dependency.godecided cross-repo vs same-repo with:When
owner/repoare omitted they are empty strings, which differ from the current repo's owner/name, so the handler took the cross-repo branch and calledGetRepositoryByOwnerAndName(ctx, "", "")→repository does not exist [id: 0, uid: 0, owner_name: , name: ](500). This fired wheneverALLOW_CROSS_REPOSITORY_DEPENDENCIESwas enabled — which is the default (MustBool(true)).Note: the IssueMeta JSON field for the repo name is
repo, notname; but even with the correct field names, a same-repo dependency required spelling out owner+repo redundantly.Fix
Treat an empty (or matching)
owner/repoas the current repository:So
POST .../dependencieswith body{"index": N}now adds a same-repo dependency and returns 201. Cross-repo lookups are unchanged. All four handlers (dependencies + blocks, create + remove) route throughgetFormIssue, so one change covers them.Tests
Added
TestAPICreateIssueDependencySameRepoOmitOwnerRepo— posts{"index": N}withowner/repoomitted and asserts 201 + the dependency row exists. Existing cross-repo permission tests still pass (go test -run IssueDependency ./tests/integration/).Fixes #22
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
🤖 Generated with Claude Code
The dependencies/blocks POST and DELETE handlers read the dependency's repo from the IssueMeta body. When owner/repo were omitted (a same-repo dependency), the empty strings differed from the current repo's owner/name, so the handler took the cross-repo branch and looked up an empty ("", "") repository — returning 500 "repository does not exist [id: 0]" whenever ALLOW_CROSS_REPOSITORY_DEPENDENCIES was on (the default). Treat an empty or matching owner/repo as the current repository so that `{"index": N}` adds a same-repo dependency and returns 201. Cross-repo lookups are unchanged. Fixes #22 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>