fix(server): keep sync enabled for token-less self-hosted forges#682
Open
hannut wants to merge 1 commit into
Open
fix(server): keep sync enabled for token-less self-hosted forges#682hannut wants to merge 1 commit into
hannut wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 anyorigin host not in
KNOWN_NON_GITHUB_GIT_HOSTSis github.com or a GHES host — areasonable default, since GHES hostnames are arbitrary and can't be allowlisted. But
when no
gh/stored token resolves for such a host,runProbe'stokenSource === 'anonymous'branch short-circuits to{ kind: 'denied' }with nonetwork call. For a self-hosted Gitea/Forgejo origin (e.g.
git.example.com) that'swrong — the user pushes fine over SSH — and
SyncEnginereacts by settingpausedReason = '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
deniedwhenhost === 'github.com'.For any other host, return
{ kind: 'unknown', error: 'host-unverified' }so callers staylenient and a genuine error surfaces only if the actual SSH push fails. github.com and
token-bearing GHES behaviour are unchanged.
The new
host-unverifiedcode is threaded through the wire schema(
packages/core/src/schemas/api/sync-seed.ts) and thePushPermissionStatusunion(
sync-engine.ts).Testing
github-permissions.test.tsasserts the anonymousnon-github.com path returns
unknown/host-unverifiedwith 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.