facebook/docusaurus · error
Failed to retrieve the git history for file "${file}" with u
Error message
Failed to retrieve the git history for file "${file}" with unexpected output: ${output} What it means
Thrown by getFileCommitDate() when git log produced non-empty output but the RESULT: prefix regex failed to match it. The function uses a 'RESULT:%ct' (or 'RESULT:%ct,%an' with includeAuthor) format and parses with a regex; a match failure indicates git emitted something unexpected — most likely a GPG signature line, a hook output, or a git version/format quirk that breaks the assumed output shape.
Source
Thrown at packages/docusaurus-utils/src/vcs/gitUtils.ts:190
// We only parse the output line starting with our "RESULT:" prefix
// See why https://github.com/facebook/docusaurus/pull/10022
const regex = includeAuthor
? /(?:^|\n)RESULT:(?<timestamp>\d+),(?<author>.+)(?:$|\n)/
: /(?:^|\n)RESULT:(?<timestamp>\d+)(?:$|\n)/;
const output = result.stdout.trim();
if (!output) {
throw new FileNotTrackedError(
`Failed to retrieve the git history for file "${file}" because the file is not tracked by git.`,
);
}
const match = output.match(regex);
if (!match) {
throw new Error(
`Failed to retrieve the git history for file "${file}" with unexpected output: ${output}`,
);
}
const timestampInSeconds = Number(match.groups!.timestamp);
const timestamp = timestampInSeconds * 1_000;
const date = new Date(timestamp);
if (includeAuthor) {
return {date, timestamp, author: match.groups!.author!};
}
return {date, timestamp};
}
let showedGitRequirementError = false;
let showedFileNotTrackedError = false;
type GitCommitInfo = {timestamp: number; author: string};View on GitHub (pinned to 3f483e80e3)
Solutions
- Inspect the output echoed in the error message — compare it to the expected 'RESULT:<timestamp>(,<author>)' shape.
- If GPG signature lines are present, ensure no global config forces `log.showSignature=true`; the per-call -c flag should override but a faulty gitrc can interfere.
- Disable any git pager or hook that could alter log output (unset GIT_PAGER, run with --no-pager for diagnostics).
- If the issue persists, reproduce manually with `git -c log.showSignature=false log --format=RESULT:%ct --max-count=1 -- <file>` to see exactly what git emits.
Example fix
# before — global config forces signed log output git config --global log.showSignature true # after git config --global --unset log.showSignature # or scope the override per-repo after the build
Defensive patterns
Strategy: try-catch
Validate before calling
import { execaSync } from 'execa';
import path from 'path';
function gitLogOutputMatchesExpected(file: string): boolean {
const r = execaSync('git', ['-c', 'log.showSignature=false', 'log', '--format=RESULT:%ct', '--max-count=1', '--', path.basename(file)], { cwd: path.dirname(file) });
return /(?:^|\n)RESULT:\d+/.test(r.stdout.trim());
}
if (!gitLogOutputMatchesExpected(file)) {
throw new Error('git log output shape is unexpected; check for GPG signatures or hooks.');
} Try / catch
try {
await getFileCommitDate(file, { age: 'newest' });
} catch (err) {
if (err instanceof Error && err.message.includes('with unexpected output')) {
// inspect err message: the raw git output is appended; check for signature lines or hook noise
}
throw err;
} Prevention
- Do not force `log.showSignature=true` globally; Docusaurus passes -c log.showSignature=false per call but a faulty gitrc can interfere.
- Avoid global git hooks or pagers that mutate log output.
- Reproduce the exact git invocation from the error to see what git emits when this fires.
When it happens
Trigger: git log ran with the RESULT: format string but its stdout, after trimming, does not contain a line matching the expected RESULT:<digits>(,<author>) pattern. The code already passes -c log.showSignature=false to suppress GPG signature noise; a mismatch suggests that suppression did not take effect, the git version misbehaves, or a custom log format hook interfered.
Common situations: Commits signed with GPG where showSignature=false did not suppress the signature (older git versions, or a config override). A global git hook (e.g. a pager or formatter) that mutates log output. A git version with a formatting bug. Concurrent git invocations interleaving output (rare thanks to GitCommandQueue).
Related errors
- Failed to parse git submodule line: ${line}
- Error while attempting to extract Docusaurus translations fr
- Can't create navigation link: no doc found with id=${docId}
- Unexpected error: file at "${filePath}" does not belong to a
- The file at path=${path.relative(process.cwd(), filePath)} l
AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12).
Data as JSON: /api/errors/e2fa46061ec89b91.
Report an issue: GitHub.