Skip to content

fix(server): keep sync enabled for token-less self-hosted forges#682

Open
hannut wants to merge 1 commit into
inkeep:mainfrom
hannut:fix/self-hosted-remote-sync
Open

fix(server): keep sync enabled for token-less self-hosted forges#682
hannut wants to merge 1 commit into
inkeep:mainfrom
hannut:fix/self-hosted-remote-sync

Conversation

@hannut

@hannut hannut commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Problem

Auto-sync silently stops for a self-hosted Gitea/Forgejo origin pushed over SSH.

The push-permission probe (packages/server/src/github-permissions.ts) presumes any
origin host not in KNOWN_NON_GITHUB_GIT_HOSTS is github.com or a GHES host — a
reasonable default, since GHES hostnames are arbitrary and can't be allowlisted. But
when no gh/stored token resolves for such a host, runProbe's
tokenSource === 'anonymous' branch short-circuits to { kind: 'denied' } with no
network call
. For a self-hosted Gitea/Forgejo origin (e.g. git.example.com) that's
wrong — the user pushes fine over SSH — and SyncEngine reacts by setting
pausedReason = 'no-push-permission' and stops committing/pushing entirely.

This is a regression from #597 (shipped in 0.31), which stopped ignoring non-GitHub
hosts; pre-0.31, such hosts were ignored and self-hosted-forge sync worked.

Fix

Only treat the anonymous (no-token) probe result as denied when host === 'github.com'.
For any other host, return { kind: 'unknown', error: 'host-unverified' } so callers stay
lenient and a genuine error surfaces only if the actual SSH push fails. github.com and
token-bearing GHES behaviour are unchanged.

The new host-unverified code is threaded through the wire schema
(packages/core/src/schemas/api/sync-seed.ts) and the PushPermissionStatus union
(sync-engine.ts).

Testing

  • New regression test in github-permissions.test.ts asserts the anonymous
    non-github.com path returns unknown/host-unverified with zero HTTP calls.
  • github-permissions.test.ts + sync-engine.test.ts: 105 passed.
  • sync-seed.test.ts (core): 58 passed.

A changeset ('@inkeep/open-knowledge': patch) is included.

The push-permission probe presumes any host not in KNOWN_NON_GITHUB_GIT_HOSTS is GitHub or GHES, because GHES hostnames are arbitrary. When no token resolved for such a host, runProbe short-circuited to `denied` with no network call, so SyncEngine paused with 'no-push-permission'. For a self-hosted Gitea/Forgejo origin pushed over SSH this is wrong — the user can push fine — and it silently disabled auto-sync (regression from inkeep#597, which stopped ignoring non-github.com hosts).

Only treat an anonymous (no-token) probe as `denied` for github.com; for any other host return `unknown/host-unverified` so callers stay lenient and a real error surfaces only if the actual push fails. github.com and token-bearing GHES behaviour are unchanged.

Adds a regression test asserting the anonymous non-github.com path returns unknown with no HTTP call, and threads the new `host-unverified` code through the wire schema and status unions.
@hannut
hannut requested a deployment to inkeep-oss-sync July 18, 2026 06:55 — with GitHub Actions Waiting
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