`interface-diff` discards the git error when resolving its default base and reports the wrong cause
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 82/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- git, node.js, typescript
- Domínio
- cli, developer-experience
Direção de pesquisa
Leia scripts/interface-diff.mjs, com foco em resolveBase() nas linhas 239–245 e no tratamento de erros em main() nas linhas 354–355. Reproduza o caso em que origin/v2/main está ausente usando as etapas fornecidas e, em seguida, verifique como o caminho explícito de --base informa o erro do Git. O trabalho estará concluído quando as falhas com a base padrão revelarem a causa subjacente, mantendo orientações úteis.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Environment
modelcontextprotocol/serversat commit005e7e6ea55a61300f05bd2e02a02bc0822db0f4- Node.js 24, any OS
- Repository script
scripts/interface-diff.mjs, also run from thelocal:gatenpm stage
Summary
resolveBase() resolves the default comparison branch with a bare try/catch. The catch binds nothing, so it cannot keep the error thrown by git(), and it rethrows a new error holding only a fixed sentence. Every way that git rev-parse --verify origin/v2/main can fail (ref not fetched, not a git repository, dubious ownership, git not installed) collapses into the same message, and for several of those the suggested remedy is wrong. The same git() call reached through --base already reports the real fatal: Needed a single revision error.
Root cause
// scripts/interface-diff.mjs:234-247
const git = (...args) => run("git", args, repoRoot).trim();
function resolveBase(base) {
if (base) return git("rev-parse", "--verify", `${base}^{commit}`);
try {
git("rev-parse", "--verify", DEFAULT_BASE_BRANCH);
} catch {
throw new Error(
`${DEFAULT_BASE_BRANCH} is not available to compare against. Run \`git fetch origin v2/main\`, or name a base with --base <ref>.`,
);
}
return git("merge-base", "HEAD", DEFAULT_BASE_BRANCH);
}
git() delegates to run(), which already builds a diagnostic error:
if (res.error) throw res.error;
if (res.status !== 0)
throw new Error(
`\`${command} ${args.join(" ")}\` exited ${res.status}:\n${tail(res.stdout)}${tail(res.stderr)}`,
);
The catch { at line 241 drops that error entirely.
Affected code
scripts/interface-diff.mjs, resolveBase() lines 239-245. The thrown message is printed by main() at lines 354-355.
Reproduction
main() checks for the built entry before resolving the base, so a build artifact must exist; dist/ is gitignored, so a placeholder is enough for this path.
git clone --single-branch --branch main https://github.com/modelcontextprotocol/servers.git /tmp/servers-no-v2
cd /tmp/servers-no-v2
git checkout 005e7e6ea55a61300f05bd2e02a02bc0822db0f4
mkdir -p src/everything/dist && printf '// placeholder\n' > src/everything/dist/index.js
git rev-parse --verify origin/v2/main; echo "raw git exit=$?"
node scripts/interface-diff.mjs; echo "exit=$?"
Observed with a clone that has no origin/v2/main:
fatal: Needed a single revision
raw git exit=128
origin/v2/main is not available to compare against. Run `git fetch origin v2/main`, or name a base with --base <ref>.
exit=1
Running the same case through the explicit branch shows what is being discarded:
node scripts/interface-diff.mjs --base origin/v2/main
`git rev-parse --verify origin/v2/main^{commit}` exited 128: fatal: Needed a single revision
With git absent from PATH, the default branch prints the byte-identical generic message, although no git fetch can fix that case.
Expected behavior
The default-base failure should preserve the underlying git diagnostic and the suggested remedy should match the failure. For a missing ref, the existing "fetch v2/main" advice is right; for a missing git binary, a non-repository directory, or a dubious-ownership error, the error should say what actually happened.
Actual behavior
All failures of the default git rev-parse --verify origin/v2/main produce one fixed sentence with no git output, exit status, or stderr, and the advice to run git fetch origin v2/main is shown even when fetching cannot help. The explicit --base path reports the real cause, so the information exists but is dropped by the wrapper.
Suggested fix
Bind the caught error and forward it as the cause, keeping the actionable hint:
try {
git("rev-parse", "--verify", DEFAULT_BASE_BRANCH);
} catch (error) {
throw new Error(
`${DEFAULT_BASE_BRANCH} is not available to compare against. Run \`git fetch origin v2/main\`, or name a base with --base <ref>.`,
{ cause: error },
);
}
If the top-level handler prints only err.message, print err.cause?.message when present (or include it in the message). That surfaces fatal: Needed a single revision, not a git repository, or spawn git ENOENT instead of the generic text.
- Linguagem predominante
- TypeScript
- Estrelas
- 92k
- Forks
- 12k
- Merge médio
- 3h 46min
- PRs com merge (30d)
- 206
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de modelcontextprotocol/servers
-
chore server-memory v2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
modelcontextprotocol/servers#5634 ·
Mantenedores costumam responder em até 1 dia
-
documentation server-memory v2
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
modelcontextprotocol/servers#5609 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
bug server-memory v2
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
modelcontextprotocol/servers#5635 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
bug server-memory v2
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 42/100
modelcontextprotocol/servers#5624 ·
Mantenedores costumam responder em até 1 dia
-
enhancement v2
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
modelcontextprotocol/servers#5611 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de modelcontextprotocol/servers
Issues semelhantes
-
bug impact:low Team: SecuritySolution Team:Defend Workflows v9.6.0
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
elastic/kibana#306401 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
agentes-chat/agentes-chat#927 ·
Mantenedores costumam responder em até 1 dia
-
[Bug]: Webapp workspace fails to render in Safari — "Can't find variable: requestIdleCallback"Abertacomp/desktop P2 type/bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
NousResearch/hermes-agent#157702 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia
-
e2e-failure ready-to-code
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
redhat-developer/rhdh-plugin-export-overlays#4794 · 1 comentário ·
Mantenedores costumam responder em até 1 dia