fix(cleanup): check public only sources instead of skipping them (#589) (#590)

Repository cleanup asked a source with no token for the account's own
repositories. On Gitea and Forgejo with an empty username that went to
/users//orgs, failed with a 404 on every run, logged that the account
might be deleted or banned, and skipped the source, so a repository
deleted there was never noticed. GitHub failed the same way with a 401.

Cleanup now treats a tokenless source the way import and the scheduler
do: no personal listing. It lists the organizations added to the source
that still hold one of its repositories, and every other repository on
it goes to the existing direct lookup, which only treats a clean 404 as
gone. Starred rows on such a source are left alone.

Gitea and GitLab sources refuse to build a /users/{name}/ listing for an
empty name. The sources docs no longer say a tokenless source lists the
user's public repositories, which stopped being true in #411.

Also makes the run now test's dates relative: its next run was
hardcoded to 2026-11-27 and the test started failing today.
This commit is contained in:
ARUNAVO RAY
2026-11-27 09:12:59 +05:30
committed by GitHub
parent c87c7e784f
commit fa493d2da6
11 changed files with 374 additions and 25 deletions
+1
View File
@@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Pages keep what they last showed in this browser tab. Going back to the Dashboard, Repositories, Organizations, Storage or Activity Log shows that data at once and refreshes it in the background, instead of starting from a skeleton and waiting for the whole list again. Nothing is written to browser storage; a reload or a new tab starts fresh
### Fixed
- **Repository cleanup never checked a public only source** (#589, thanks @zwimer). For a source with no token it asked for the account's own repositories, which on Gitea and Forgejo went to `/users//orgs` when the username was empty too. The request failed on every run, the log said the account might be deleted or banned, and the source was skipped, so a repository deleted there was never noticed. Cleanup now lists the organizations added to such a source and looks up its other repositories one at a time; starred repositories on it are left alone. Gitea and GitLab sources also refuse to build a listing address for an empty username
- **A mirror run deleted a regular repository that had the name it needed**, then created the mirror in its place. It now leaves that repository alone and fails with a message saying to rename or delete it on the destination, or to give the repository another destination. A failed import looks the same and is deleted by hand from its page on the destination, as before
- **Repository cleanup could archive or delete a repository that was not the orphan's mirror**, with **Apply to the destination too** on. A row with no recorded location was acted on wherever the mirror strategy would put it, whatever sat there: a regular repository, another source's mirror of the same name, or, through the redirect Gitea leaves at the old address of a renamed repository, wherever that repository went. Cleanup now only acts on a repository it has confirmed mirrors that source, at its current address, and deletes never follow a redirect. Run now, the cleanup event and the notification name what was left alone
- **Creating an OAuth application with a refused redirect URL failed with a 500** that hid the reason. `POST /api/sso/applications` now answers 400 with what is wrong and what to use instead (web applications need https on a real host name; `type: "native"` allows http on localhost). Changing redirect URLs with `PUT` follows the same rules per application type, which it did not before; a URL the application already has can stay
+178
View File
@@ -0,0 +1,178 @@
/**
* Repository cleanup on a public only source (#589). A source with no token
* has no account, so cleanup must not ask for the account's repositories
* (that built /users//orgs on Gitea and failed on every run). It lists the
* organizations added to the source and checks every other repository on
* its own.
*
* Runs against the real schema in an in-memory SQLite database that replaces
* @/lib/db through mock.module, with the source host faked, so the file runs
* in its own process.
*/
import { beforeEach, describe, expect, mock, test } from "bun:test";
import { Database } from "bun:sqlite";
import { drizzle } from "drizzle-orm/bun-sqlite";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import * as schema from "@/lib/db/schema";
import { runsIsolated } from "@/tests/isolated";
const isolated = runsIsolated(import.meta.path);
const sqlite = new Database(":memory:");
const db = drizzle({ client: sqlite });
function applyMigrations(): void {
const folder = join(process.cwd(), "drizzle");
const journal = JSON.parse(readFileSync(join(folder, "meta", "_journal.json"), "utf8")) as {
entries: { tag: string }[];
};
for (const entry of journal.entries) {
const sql = readFileSync(join(folder, `${entry.tag}.sql`), "utf8");
for (const statement of sql.split("--> statement-breakpoint")) {
if (statement.trim()) sqlite.run(statement);
}
}
}
const listedOrganizations: string[] = [];
const checkedRepositories: string[] = [];
let organizationListing: (name: string) => Promise<any[]> = async () => [];
let stillThere = new Set<string>();
const gitRepo = (fullName: string) => ({ fullName, name: fullName.split("/")[1], owner: fullName.split("/")[0] });
/** A Gitea source with neither username nor token. */
const provider = {
connection: { token: "", username: "", url: "https://git.example.org", provider: "gitea" },
listRepositories: async () => {
throw new Error("listRepositories must not run for a public only source");
},
listStarredRepositories: async () => {
throw new Error("listStarredRepositories must not run for a public only source");
},
listOrganizationRepositories: async (name: string) => {
listedOrganizations.push(name);
return organizationListing(name);
},
getRepository: async (owner: string, name: string) => {
checkedRepositories.push(`${owner}/${name}`);
return stillThere.has(`${owner}/${name}`) ? gitRepo(`${owner}/${name}`) : null;
},
isRepositoryStarred: async () => {
throw new Error("isRepositoryStarred must not run for a public only source");
},
};
if (isolated) {
process.env.ENCRYPTION_SECRET ??= "cleanup-public-only-test-secret-012345";
applyMigrations();
// Copy the real exports before mocking: mock.module patches the namespace.
const realProviders = { ...(await import("@/lib/source-providers")) };
const realSources = { ...(await import("@/lib/sources")) };
mock.module("@/lib/db", () => ({ ...schema, db }));
mock.module("@/lib/source-providers", () => ({
...realProviders,
createSourceProviderFromSource: () => provider,
isRepositoryFromConfiguredSource: () => true,
}));
mock.module("@/lib/sources", () => ({
...realSources,
listSources: async () => [
{ id: "src-pub", name: "Gitea / Forgejo", provider: "gitea", url: "https://git.example.org", username: "", token: null, enabled: true },
],
}));
}
const { identifyOrphanedRepositories } = isolated
? await import("@/lib/repository-cleanup-service")
: ({} as Partial<typeof import("@/lib/repository-cleanup-service")>);
const CONFIG = {
id: "config-1",
userId: "user-1",
githubConfig: { includeStarred: true },
cleanupConfig: { enabled: true, deleteIfNotInGitHub: true, orphanedRepoAction: "archive" },
};
function repoRow(fullName: string, extra: Record<string, unknown> = {}) {
const [owner, name] = fullName.split("/");
return {
id: `repo-${fullName.replace("/", "-")}`,
userId: "user-1",
configId: "config-1",
sourceId: "src-pub",
sourceProvider: "gitea",
sourceUrl: "https://git.example.org",
name,
fullName,
normalizedFullName: fullName.toLowerCase(),
url: `https://git.example.org/${fullName}`,
cloneUrl: `https://git.example.org/${fullName}.git`,
owner,
defaultBranch: "main",
status: "mirrored",
...extra,
} as any;
}
if (isolated) {
describe("repository cleanup on a public only source (#589)", () => {
beforeEach(async () => {
for (const table of ["repositories", "organizations", "configs", "users"]) {
sqlite.run(`DELETE FROM ${table}`);
}
listedOrganizations.length = 0;
checkedRepositories.length = 0;
organizationListing = async (name) => (name === "acme" ? [gitRepo("acme/kept")] : []);
stillThere = new Set(["someone/single", "other-org/tool"]);
sqlite.run(`INSERT INTO users (id, email) VALUES ('user-1', 'user-1@example.com')`);
await db.insert(schema.configs).values({
id: "config-1",
userId: "user-1",
name: "Default",
isActive: true,
githubConfig: CONFIG.githubConfig as any,
giteaConfig: { url: "https://gitea.example.com", defaultOwner: "mirror" } as any,
scheduleConfig: { enabled: false } as any,
cleanupConfig: CONFIG.cleanupConfig as any,
});
await db.insert(schema.organizations).values([
// Added to the public only source, and holds tracked repositories.
{ id: "org-acme", userId: "user-1", configId: "config-1", sourceId: "src-pub", name: "acme", normalizedName: "acme", avatarUrl: "" },
// Added to the source, but nothing of it is tracked: not worth a listing.
{ id: "org-empty", userId: "user-1", configId: "config-1", sourceId: "src-pub", name: "empty", normalizedName: "empty", avatarUrl: "" },
] as any);
await db.insert(schema.repositories).values([
repoRow("acme/kept", { organization: "acme" }),
repoRow("acme/gone", { organization: "acme" }),
// Added by URL: no organization row behind it.
repoRow("someone/single"),
repoRow("other-org/tool", { organization: "other-org" }),
// A star cannot be checked without an account.
repoRow("starred/thing", { isStarred: true }),
]);
});
test("lists the added organization, checks the rest one by one and finds the deleted repository", async () => {
const orphaned = await identifyOrphanedRepositories!(CONFIG);
expect(orphaned.map((repo: any) => repo.fullName)).toEqual(["acme/gone"]);
expect(listedOrganizations).toEqual(["acme"]);
expect(checkedRepositories.sort()).toEqual(["acme/gone", "other-org/tool", "someone/single"]);
});
test("a failed organization listing falls back to checking that organization's repositories", async () => {
organizationListing = async () => {
throw new Error("503 Service Unavailable");
};
stillThere.add("acme/kept");
const orphaned = await identifyOrphanedRepositories!(CONFIG);
expect(orphaned.map((repo: any) => repo.fullName)).toEqual(["acme/gone"]);
expect(checkedRepositories.sort()).toEqual(["acme/gone", "acme/kept", "other-org/tool", "someone/single"]);
});
});
}
+6 -3
View File
@@ -35,13 +35,16 @@ function applyMigrations(): void {
}
const DAY_MS = 24 * 60 * 60 * 1000;
const LAST_RUN = new Date("2026-11-20T00:00:00Z");
const NEXT_RUN = new Date("2026-11-27T00:00:00Z");
// Whole seconds, a week either side of now: the next run must stay in the future.
const NOW_S = Math.floor(Date.now() / 1000) * 1000;
const LAST_RUN = new Date(NOW_S - 7 * DAY_MS);
const NEXT_RUN = new Date(NOW_S + 7 * DAY_MS);
/** The fake source host: lists nothing and finds nothing, so a repository from it is gone. */
let listRepositories: () => Promise<any[]> = async () => [];
const provider = {
connection: {},
// A token, so cleanup takes the account listing (no token is the public only path, #589).
connection: { token: "token" },
listRepositories: () => listRepositories(),
listStarredRepositories: async () => [],
getRepository: async () => null,
+50 -1
View File
@@ -17,7 +17,12 @@
*/
import { describe, test, expect } from "bun:test";
import { resolveOrphanVerdict, planOrphanedRepoAction } from "./repository-cleanup-service";
import {
resolveOrphanVerdict,
planOrphanedRepoAction,
organizationsToListForPublicSource,
listPublicOnlySourceRepositories,
} from "./repository-cleanup-service";
describe("resolveOrphanVerdict", () => {
test("repo present in the bulk fetch is never orphaned, regardless of the direct check", () => {
@@ -82,3 +87,47 @@ describe("planOrphanedRepoAction", () => {
expect(planOrphanedRepoAction("delete", true)).toEqual({ gitea: "delete", db: "delete" });
});
});
/**
* #589: a public only source has no account, so cleanup lists the
* organizations added to it and checks the rest one by one.
*/
describe("organizationsToListForPublicSource", () => {
const repos = [
{ sourceId: "pub", organization: "Acme" },
{ sourceId: "pub", organization: "acme" },
{ sourceId: "pub", organization: "loose-org" },
{ sourceId: "pub", organization: null },
{ sourceId: "other", organization: "widgets" },
];
const orgs = [
{ sourceId: "pub", name: "Acme", normalizedName: "acme" },
{ sourceId: "pub", name: "idle", normalizedName: "idle" },
{ sourceId: "other", name: "widgets", normalizedName: "widgets" },
{ sourceId: "other", name: "loose-org", normalizedName: "loose-org" },
];
test("only organizations added to this source that hold one of its repositories", () => {
expect(organizationsToListForPublicSource("pub", repos, orgs)).toEqual(["Acme"]);
});
test("nothing to list when the source holds no organization repositories", () => {
expect(organizationsToListForPublicSource("pub", [{ sourceId: "pub", organization: null }], orgs)).toEqual([]);
});
});
describe("listPublicOnlySourceRepositories", () => {
test("joins the organization listings and skips one that fails", async () => {
const listed: string[] = [];
const provider = {
async listOrganizationRepositories(name: string) {
listed.push(name);
if (name === "broken") throw new Error("503");
return [{ fullName: `${name}/app` }] as any[];
},
};
const repos = await listPublicOnlySourceRepositories(provider, ["acme", "broken", "tools"], "Codeberg");
expect(listed).toEqual(["acme", "broken", "tools"]);
expect(repos.map((repo) => repo.fullName)).toEqual(["acme/app", "tools/app"]);
});
});
+105 -16
View File
@@ -4,7 +4,7 @@
* but are no longer present in GitHub (e.g., unstarred repositories)
*/
import { db, configs, repositories } from '@/lib/db';
import { db, configs, organizations, repositories } from '@/lib/db';
import { eq, and, or, sql, not, inArray } from 'drizzle-orm';
import {
describeSource,
@@ -22,6 +22,7 @@ import { getDecryptedGiteaToken } from '@/lib/utils/config-encryption';
import { publishEvent } from '@/lib/events';
import { triggerRepositoryCleanupNotification, triggerSourceMissingNotification } from '@/lib/notification-service';
import { isMirrorableGitHubRepo } from '@/lib/repo-eligibility';
import type { GitRepo } from '@/types/Repository';
let cleanupInterval: NodeJS.Timeout | null = null;
let isCleanupRunning = false;
@@ -85,6 +86,60 @@ export function planOrphanedRepoAction(
return { gitea: deleteFromGitea ? "delete" : "none", db: "delete" };
}
/**
* The organizations a public only source lists during cleanup (#589): the
* ones added to that source that still hold one of its repositories. Any
* other repository on the source (one added by URL, or one in an
* organization that was never added) is checked on its own, which is
* cheaper than listing a whole organization to vouch for a single row.
*/
export function organizationsToListForPublicSource(
sourceId: string,
sourceRepos: Array<{ sourceId?: string | null; organization?: string | null }>,
organizationRows: Array<{ sourceId?: string | null; name: string; normalizedName?: string | null }>
): string[] {
const held = new Set(
sourceRepos
.filter(repo => repo.sourceId === sourceId && repo.organization)
.map(repo => repo.organization!.toLowerCase())
);
const names = new Map<string, string>();
for (const org of organizationRows) {
if (org.sourceId !== sourceId) continue;
const key = (org.normalizedName || org.name).toLowerCase();
if (held.has(key) && !names.has(key)) names.set(key, org.name);
}
return [...names.values()];
}
/**
* What a public only source (no token) can vouch for in one pass (#589).
* It has no account, so the personal, collaborator and starred listings are
* skipped, the same way import and the scheduler skip them. The given
* organizations are listed instead. A failed organization listing is logged
* and leaves that organization's repositories to the direct check, which
* only treats a clean 404 as gone.
*/
export async function listPublicOnlySourceRepositories(
provider: { listOrganizationRepositories(name: string): Promise<GitRepo[]> },
organizationNames: string[],
sourceName: string
): Promise<GitRepo[]> {
const repos: GitRepo[] = [];
for (const name of organizationNames) {
try {
repos.push(...(await provider.listOrganizationRepositories(name)));
} catch (error) {
console.warn(
`[Repository Cleanup] Could not list organization ${name} on source ${sourceName}, checking its repositories one by one instead: ${
error instanceof Error ? error.message : String(error)
}`
);
}
}
return repos;
}
/**
* Identify orphaned repositories for a user
* These are repositories that exist in our database (and likely in Gitea)
@@ -164,6 +219,16 @@ async function scanForOrphanedRepositories(config: any): Promise<OrphanScan> {
return true;
});
// Public only sources list the organizations added to them (#589).
const organizationRows = await db
.select({
sourceId: organizations.sourceId,
name: organizations.name,
normalizedName: organizations.normalizedName,
})
.from(organizations)
.where(eq(organizations.userId, userId));
const orphanedById = new Map<string, any>();
// Only a clean sighting clears the wait (#549); an error proves nothing.
const seenAgainById = new Map<string, any>();
@@ -181,26 +246,45 @@ async function scanForOrphanedRepositories(config: any): Promise<OrphanScan> {
// The source host with its token decrypted (GitHub honors GH_API_URL and tracks rate limits)
const sourceProvider = createSourceProviderFromSource(source, { userId });
const sourceConnection = sourceProvider.connection;
// No token means no account (#589): there is nothing personal to list,
// and a listing for a blank user fails on every run.
const publicOnly = (sourceConnection.token ?? '').trim() === '';
let allGithubRepos: any[] = [];
try {
// Fetch source data. Always include collaborator repos and bypass the
// organization allowlist here regardless of the user's import filters,
// otherwise repos previously mirrored as a collaborator or from an org the
// user later removed from the allowlist would be flagged as orphaned and
// archived/deleted as soon as the user narrows those filters.
const [basicAndForkedRepos, starredRepos] = await Promise.all([
sourceProvider.listRepositories(config, {
includeCollaboratorReposOverride: true,
includeAllOrgsOverride: true,
}),
config.githubConfig?.includeStarred
? sourceProvider.listStarredRepositories(config)
: Promise.resolve([]),
]);
if (publicOnly) {
const organizationNames = organizationsToListForPublicSource(
source.id,
sourceOwnedRepos.filter(repo => repo.status !== 'archived' && !repo.isArchived),
organizationRows
);
console.log(
`[Repository Cleanup] Source ${source.name} is public only: listing ${organizationNames.length} organization(s) added to it and checking its other repositories one by one`
);
allGithubRepos = await listPublicOnlySourceRepositories(
sourceProvider,
organizationNames,
source.name
);
} else {
// Fetch source data. Always include collaborator repos and bypass the
// organization allowlist here regardless of the user's import filters,
// otherwise repos previously mirrored as a collaborator or from an org the
// user later removed from the allowlist would be flagged as orphaned and
// archived/deleted as soon as the user narrows those filters.
const [basicAndForkedRepos, starredRepos] = await Promise.all([
sourceProvider.listRepositories(config, {
includeCollaboratorReposOverride: true,
includeAllOrgsOverride: true,
}),
config.githubConfig?.includeStarred
? sourceProvider.listStarredRepositories(config)
: Promise.resolve([]),
]);
allGithubRepos = [...basicAndForkedRepos, ...starredRepos];
allGithubRepos = [...basicAndForkedRepos, ...starredRepos];
}
} catch (githubError: any) {
// Handle source API errors gracefully
console.warn(`[Repository Cleanup] Source API error for user ${userId} on source ${source.name}: ${githubError.message}`);
@@ -256,6 +340,11 @@ async function scanForOrphanedRepositories(config: any): Promise<OrphanScan> {
console.log(`[Repository Cleanup] Skipping starred repo ${repo.fullName} - starred repos not being fetched from the source`);
return false;
}
// Stars belong to an account; a public only source has none to ask.
if (repo.isStarred && publicOnly) {
console.log(`[Repository Cleanup] Skipping starred repo ${repo.fullName} - source ${source.name} has no account to check stars with`);
return false;
}
const githubRepo = githubReposByFullName.get(repo.fullName);
if (!githubRepo) {
@@ -156,6 +156,14 @@ describe("GiteaSourceProvider", () => {
expect(calls.every((c) => c.headers.Authorization === undefined)).toBe(true);
});
test("without a username or token it refuses to list instead of asking for /users//... (#589)", async () => {
installFetch(() => json({ message: "unexpected" }, { status: 500 }));
const anonymous = new GiteaSourceProvider({ ...connection, username: "", token: "" });
await expect(anonymous.listRepositories({})).rejects.toThrow("no username or token");
await expect(anonymous.listStarredRepositories({})).rejects.toThrow("no username or token");
expect(calls).toHaveLength(0);
});
test("getRepository returns null on 404 and marks org owned repositories", async () => {
installFetch((url) => {
if (url.endsWith("/api/v1/repos/acme/tool")) return json(repo({ name: "tool", owner: "acme" }));
+7 -1
View File
@@ -239,8 +239,14 @@ export class GiteaSourceProvider implements SourceProvider {
return this.hasToken ? { Authorization: `token ${this.connection.token}` } : {};
}
/** The source's username for the /users/{name}/... listings. */
private encodedUser(): string {
return encodeURIComponent(this.connection.username);
const username = this.connection.username.trim();
// A blank name would build /users//... and fail on every call (#589).
if (!username) {
throw new Error("This source has no username or token, so there is no account to list repositories for.");
}
return encodeURIComponent(username);
}
private async paginate<T>(
+8
View File
@@ -343,6 +343,14 @@ describe("GitLabSourceProvider", () => {
expect(repos).toHaveLength(1);
});
test("without a username or token it refuses to list instead of asking for /users//... (#589)", async () => {
installFetch(() => json([project()]));
const anonymous = new GitLabSourceProvider({ ...connection, username: "", token: "" });
await expect(anonymous.listRepositories({})).rejects.toThrow("no username or token");
await expect(anonymous.listStarredRepositories({})).rejects.toThrow("no username or token");
expect(calls).toHaveLength(0);
});
test("starred projects are flagged as starred", async () => {
installFetch(() => json([project()]));
const repos = await new GitLabSourceProvider(connection).listStarredRepositories({});
+7 -1
View File
@@ -245,8 +245,14 @@ export class GitLabSourceProvider implements SourceProvider {
return this.hasToken ? { "PRIVATE-TOKEN": this.connection.token } : {};
}
/** The source's username for the /users/{name}/... listings. */
private encodedUser(): string {
return encodeURIComponent(this.connection.username);
const username = this.connection.username.trim();
// A blank name would build /users//... and fail on every call (#589).
if (!username) {
throw new Error("This source has no username or token, so there is no account to list repositories for.");
}
return encodeURIComponent(username);
}
private async paginate<T>(
+2 -1
View File
@@ -54,8 +54,9 @@ On Gitea and Forgejo, cleanup only archives or deletes a repository it has confi
Cleanup is careful about what it calls an orphan, because the cost of a false positive is an archived or deleted backup.
- It first lists everything the source token can see, including collaborator repositories and every organization regardless of the import filters, so narrowing a filter later cannot make old mirrors look orphaned.
- A public only source, one without a token, has no account to list. Cleanup lists the organizations you added to it instead, and every other repository on it, such as one added by URL, goes straight to the direct lookup below. Its starred repositories are left alone. On GitHub these lookups count against the anonymous limit of 60 requests an hour.
- A repository missing from that list is only a candidate. It counts as orphaned when a direct lookup of that repository on the source returns a clean 404 as well. Any other outcome, including a rate limit, a network error or a 5xx, leaves it alone.
- If the source API cannot be reached at all, or answers 403 or 404 for the account itself, the whole run is skipped.
- If the source API cannot be reached at all, or answers 403 or 404 for the account itself, that source is skipped until the next run.
- Repositories imported from a previous source, and rows mirrored to a previous destination, are not touched.
## Database maintenance
+2 -2
View File
@@ -61,7 +61,7 @@ The card lists the scopes it needs and links to the token page of the selected i
The card asks for `admin:org` on GitHub; `read:org`, one of its checkboxes, is all the app uses. [Tokens and permissions](/docs/tokens/) explains each scope.
Without a token, GitLab and Gitea / Forgejo only show the configured user's public repositories and starred repositories. Adding a public repository by URL works without a token on every source.
A source without a token is a public only source, described further down: it finds no personal or starred repositories, even with a username filled in. Adding a public repository by URL works without a token on every source.
Tokens are encrypted with AES-256-GCM before they are stored, whether they come from the form or from the environment.
@@ -108,7 +108,7 @@ A save that tries to switch a locked source without that confirmation is refused
**Removing a source that has imported repositories asks for confirmation.** Those mirrors keep syncing on the destination with the credentials they were created with, but cleanup leaves them alone.
**Public only sources.** Adding a public organization without an account, see [Repositories and organizations](/docs/repositories-and-organizations/), creates a source with no token, shown as **Public only** on the Sources card. It imports the public repositories of the organizations you add, but finds no personal or starred repositories. Its API calls are anonymous, so on GitHub they share the limit of 60 requests an hour per IP address, and a large organization can end up with partial metadata; the mirrors themselves are plain git clones and use no API requests. Add a username and token to the source to turn it into a normal one.
**Public only sources.** Adding a public organization without an account, see [Repositories and organizations](/docs/repositories-and-organizations/), creates a source with no token, shown as **Public only** on the Sources card. It imports the public repositories of the organizations you add, but finds no personal or starred repositories. Its API calls are anonymous, so on GitHub they share the limit of 60 requests an hour per IP address, and a large organization can end up with partial metadata; the mirrors themselves are plain git clones and use no API requests. Repository cleanup checks it too: it lists the organizations you added to the source and looks up its other repositories one at a time. Add a username and token to the source to turn it into a normal one.
**Each repository remembers its host.** A row imported from one host is never mirrored with another host's token, so switching sources cannot send a token to the wrong server.