Skip to content

fix: skip fork creation when user owns the repository (issue #1206)#1235

Open
konard wants to merge 4 commits intomainfrom
issue-1206-49c410661e3f
Open

fix: skip fork creation when user owns the repository (issue #1206)#1235
konard wants to merge 4 commits intomainfrom
issue-1206-49c410661e3f

Conversation

@konard
Copy link
Contributor

@konard konard commented Feb 7, 2026

Summary

  • Add owner detection in setupRepository() to skip fork creation when the authenticated user owns the target repository
  • Prevents HTTP 403: Resource not accessible by personal access token error from GitHub when attempting to fork own repository
  • When owner is detected, returns early to work directly on the repository without forking

Root Cause

The setupRepository function in src/solve.repository.lib.mjs entered fork creation logic whenever argv.fork was true, without checking if the current user is the repository owner. GitHub does not allow forking your own repositories and returns HTTP 403, causing solve to crash.

The --auto-fork path in solve.mjs was not affected because it already checks permissions.push/admin/maintain before enabling fork mode (owners always have admin access).

Changes

File Description
src/solve.repository.lib.mjs Added currentUser === owner check after retrieving current user, before fork conflict detection
tests/test-owner-fork-detection.mjs 10 tests verifying owner detection logic
docs/case-studies/issue-1206/README.md Case study with timeline, root cause analysis, and solution details
.changeset/fix-owner-fork-detection.md Changeset for patch release

Test Plan

  • 10 new tests pass (node tests/test-owner-fork-detection.mjs)
  • 10 existing fork validation tests pass (node tests/test-fork-parent-validation.mjs)
  • No regressions in related tests

Fixes #1206

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #1206
@konard konard self-assigned this Feb 7, 2026
When a user runs solve with --fork on their own repository, GitHub
returns HTTP 403 because users cannot fork their own repos. Add owner
detection in setupRepository that checks currentUser === owner before
attempting any fork operations, returning early to work directly on
the repository instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@konard konard changed the title [WIP] Solve attempts to fork when user owns the repository (HTTP 403) fix: skip fork creation when user owns the repository (issue #1206) Feb 7, 2026
@konard konard marked this pull request as ready for review February 7, 2026 22:35
konard and others added 2 commits February 7, 2026 23:36
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@konard
Copy link
Contributor Author

konard commented Feb 7, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $5.088602 USD
  • Calculated by Anthropic: $4.280010 USD
  • Difference: $-0.808592 (-15.89%)
    📎 Log file uploaded as Gist (972KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

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.

Solve attempts to fork when user owns the repository (HTTP 403)

1 participant