abhigyanpatwari/GitNexus · error · Error
must not include query strings or fragments
Error message
must not include query strings or fragments
What it means
validateAutoSyncRemoteUrl() rejects remote URLs containing '?' or '#' because query strings and fragments are meaningless in git SSH remotes and would corrupt repo identity/clone URL derivation. The message is thrown before the SSH-URL format check, so it fires for any remote containing those characters.
Source
Thrown at gitnexus/src/core/auto-sync/config.ts:286
});
}
if (errors.length > 0) throw new Error(errors.join('; '));
return {
configPath,
syncIntervalMinutes: interval,
repoGitTimeoutMs,
analyzeTimeoutMs,
maxConcurrency,
analyzeFailureThreshold,
projects,
};
}
export function validateAutoSyncRemoteUrl(remoteUrl: string): void {
const trimmed = remoteUrl.trim();
if (trimmed.includes('?') || trimmed.includes('#')) {
throw new Error('must not include query strings or fragments');
}
const match = /^git@([^:\s/]+):([^\s]+)$/.exec(trimmed);
if (!match) {
throw new Error('must use an SSH URL on github.com, gitlab.com, or gitee.com');
}
const host = match[1].toLowerCase();
const repoPath = match[2];
if (!ALLOWED_REMOTE_HOSTS.has(host)) {
throw new Error('host must be one of github.com, gitlab.com, or gitee.com');
}
const pathParts = repoPath.split('/');
// Every segment becomes a directory component: the namespace segments build
// the clone path and the last one names the repo. So each is held to the same
// charset, which is what keeps a separator out of a segment — on Windows
// `..\..\outside` is traversal even though the segment is not literally `..`,
// and testing the raw string for `..` instead would reject an ordinary
// `foo..bar`. Traversal is a whole segment; a separator is a character.
const namespaceParts = pathParts.slice(0, -1);View on GitHub (pinned to 0d1aed942f)
Solutions
- Strip everything from '?' onward in the remote URL.
- Strip everything from '#' onward in the remote URL.
- Use the plain SSH form: git@github.com:org/repo.git (allowed hosts: github.com, gitlab.com, gitee.com).
- If you need a specific branch, configure it via the auto-sync branch option, not the URL.
- Fix the source script/template that injected the query or fragment.
Example fix
// before remotes: - git@github.com:org/repo.git?ref=main // after remotes: - git@github.com:org/repo.git
Defensive patterns
Strategy: validation
Validate before calling
for (const url of cfg.remotes) {
if (url.includes('?') || url.includes('#')) throw new Error(`remote ${url} must not contain ? or #`);
if (!/^git@[^:\s/]+:[^\s]+$/.test(url.trim())) throw new Error(`remote ${url} must be an SSH URL`);
} Prevention
- Copy the git clone (SSH) URL, never the browser address bar URL
- Never append ?query or #fragment to git remotes
- Use only github.com, gitlab.com, or gitee.com SSH hosts
- Sanitize URL-building templates that could leak '?' placeholders
When it happens
Trigger: Configuring an auto-sync remote like git@github.com:org/repo.git?ref=main or a URL copied from a web page that includes #readme, or a stale HTTPS-style URL pasted into the SSH remotes list.
Common situations: Copy-pasting the browser URL (with #fragment) instead of the git clone URL, appending branch/query parameters to a remote, or template strings that leaked '?' into the config.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- must not contain backticks
- must not end with "/" or "."
- must not contain consecutive slashes
- must not contain "@{"
- must not contain hidden, trailing-dot, or .lock path compone
AI-assisted analysis of abhigyanpatwari/GitNexus@0d1aed942f (2026-09-08).
Data as JSON: /api/errors/ec207f6ee47be01e.
Report an issue: GitHub.