Skip to content

feat: check repository access before registration - #20

Merged
qiansc merged 1 commit into
mainfrom
feat/register-access-check
Nov 14, 2026
Merged

qiansc merged 1 commit into
mainfrom
feat/register-access-check

Conversation

@qiansc

@qiansc qiansc commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Background

Repositories were often registered although they could not be fetched (no read access); the failure only showed up in the first sync, after the registration was stored.

Changes

  • Registering a new repository first lists the remote HEAD with the credentials its fetches will use (personal token, site-wide token, then anonymous where the source allows it), outside the registration lock, sharing the remote-lookup slots, for at most 20 seconds.
  • A failed check stores nothing. Credential failures (missing, rejected, denied, not found) carry code_provider, settings_url (user token settings for signed-in callers, the site-wide token for the service credential) and guidance; a timeout returns retryable 504 ACCESS_CHECK_TIMEOUT.
  • POST /api/admin/v1/repos/access-check runs the same check without registering.
  • Registration form: locked while checking; on failure the input is kept, the token settings open in a new window, and Check again resubmits with the same idempotency key.
  • Docs: docs/interfaces.md.

Risk

  • Every new registration waits for one remote request (≤20 s).
  • A repository can no longer be registered before any token can read it.

Compatibility

  • Existing names are not checked; replays and 409 REPOSITORY_EXISTS are unchanged.
  • Registration can now fail with the existing fetch codes or ACCESS_CHECK_TIMEOUT.

Testing

  • bun run check and go test ./... pass.
  • New tests: unfetchable registration stores nothing and succeeds on retry; replays and taken names do not contact the host; settings links for users and the service credential; no link when the host is unreachable; no scratch directories left.

🤖 Generated with Claude Code

Registering a new repository first lists the remote HEAD with the tokens
its fetches will use (personal, site-wide, then anonymous where allowed).
Unreadable repositories are not stored; credential failures carry
code_provider, settings_url and guidance pointing at the token settings.
POST /api/admin/v1/repos/access-check runs the same check alone. The
website locks the form while checking, keeps its input on failure and
offers to open the token settings in a new window with a retry button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qiansc
qiansc merged commit 8300238 into main Nov 14, 2026
3 checks passed
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.

1 participant