From e2e2595323dd31cabffe8b28d13c545b7d658440 Mon Sep 17 00:00:00 2001 From: benesjan Date: Sat, 11 Apr 2026 03:58:39 +0000 Subject: [PATCH] fix: check all aztec-nr dependency tags, not just aztec Broaden `warnIfAztecVersionMismatch` to flag any dependency sourced from the AztecProtocol/aztec-nr repo whose tag does not match the CLI version, instead of only checking the dep literally named `aztec`. The warning now names the offending dep so users know exactly which one to bump. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../warn_if_aztec_version_mismatch.test.ts | 69 +++++++++++++++++++ .../utils/warn_if_aztec_version_mismatch.ts | 47 +++++++++---- 2 files changed, 104 insertions(+), 12 deletions(-) diff --git a/yarn-project/aztec/src/cli/cmds/utils/warn_if_aztec_version_mismatch.test.ts b/yarn-project/aztec/src/cli/cmds/utils/warn_if_aztec_version_mismatch.test.ts index 490b1281bfe1..544e201bfc0d 100644 --- a/yarn-project/aztec/src/cli/cmds/utils/warn_if_aztec_version_mismatch.test.ts +++ b/yarn-project/aztec/src/cli/cmds/utils/warn_if_aztec_version_mismatch.test.ts @@ -67,6 +67,75 @@ describe('warnIfAztecVersionMismatch', () => { expect(logMessages[0]).toContain('v1.0.0'); }); + it('warns when a non-aztec aztec-nr dependency tag does not match the CLI version', async () => { + await makePackage(tempDir, 'project', 'contract', { + // eslint-disable-next-line camelcase + uint_note: '{ git = "https://github.com/AztecProtocol/aztec-nr", tag = "v0.99.0", directory = "uint-note" }', + }); + + await warnIfAztecVersionMismatch(log, '1.0.0'); + + expect(logMessages).toHaveLength(1); + expect(logMessages[0]).toContain('WARNING'); + expect(logMessages[0]).toContain('uint_note'); + expect(logMessages[0]).toContain('v0.99.0'); + expect(logMessages[0]).toContain('v1.0.0'); + }); + + it('warns about a sibling aztec-nr dependency even when the aztec dependency matches', async () => { + await makePackage(tempDir, 'project', 'contract', { + aztec: '{ git = "https://github.com/AztecProtocol/aztec-nr", tag = "v1.0.0", directory = "aztec" }', + // eslint-disable-next-line camelcase + uint_note: '{ git = "https://github.com/AztecProtocol/aztec-nr", tag = "v0.99.0", directory = "uint-note" }', + }); + + await warnIfAztecVersionMismatch(log, '1.0.0'); + + expect(logMessages).toHaveLength(1); + expect(logMessages[0]).toContain('WARNING'); + expect(logMessages[0]).toContain('uint_note'); + expect(logMessages[0]).not.toMatch(/—\s*aztec\s*\(/); + }); + + it('does not warn when multiple aztec-nr dependencies all match the CLI version', async () => { + await makePackage(tempDir, 'project', 'contract', { + aztec: '{ git = "https://github.com/AztecProtocol/aztec-nr", tag = "v1.0.0", directory = "aztec" }', + // eslint-disable-next-line camelcase + uint_note: '{ git = "https://github.com/AztecProtocol/aztec-nr", tag = "v1.0.0", directory = "uint-note" }', + // eslint-disable-next-line camelcase + compressed_string: + '{ git = "https://github.com/AztecProtocol/aztec-nr", tag = "v1.0.0", directory = "compressed-string" }', + }); + + await warnIfAztecVersionMismatch(log, '1.0.0'); + + expect(logMessages.filter(m => m.includes('WARNING'))).toHaveLength(0); + }); + + it('does not warn for unrelated third-party git dependencies', async () => { + await makePackage(tempDir, 'project', 'contract', { + aztec: '{ git = "https://github.com/AztecProtocol/aztec-nr", tag = "v1.0.0", directory = "aztec" }', + // eslint-disable-next-line camelcase + noir_string_search: '{ git = "https://github.com/noir-lang/noir_string_search", tag = "v0.1.0" }', + }); + + await warnIfAztecVersionMismatch(log, '1.0.0'); + + expect(logMessages.filter(m => m.includes('WARNING'))).toHaveLength(0); + }); + + it('normalizes trailing slashes and .git suffixes in the aztec-nr git URL', async () => { + await makePackage(tempDir, 'project', 'contract', { + aztec: '{ git = "https://github.com/AztecProtocol/aztec-nr.git", tag = "v1.0.0", directory = "aztec" }', + // eslint-disable-next-line camelcase + uint_note: '{ git = "https://github.com/AztecProtocol/aztec-nr/", tag = "v1.0.0", directory = "uint-note" }', + }); + + await warnIfAztecVersionMismatch(log, '1.0.0'); + + expect(logMessages.filter(m => m.includes('WARNING'))).toHaveLength(0); + }); + it('warns when the CLI version is not available', async () => { await makePackage(tempDir, 'project', 'contract'); diff --git a/yarn-project/aztec/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts b/yarn-project/aztec/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts index 58c68c1ced90..3cedfa39a660 100644 --- a/yarn-project/aztec/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +++ b/yarn-project/aztec/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts @@ -7,7 +7,25 @@ import { join } from 'path'; import { collectCrateDirs } from './collect_crate_dirs.js'; -/** Warns if the `aztec` dependency tag in any crate's Nargo.toml doesn't match the CLI version. */ +/** Returns true if the given git URL points to the AztecProtocol/aztec-nr repository. */ +function isAztecNrGitUrl(gitUrl: string): boolean { + let url: URL; + try { + url = new URL(gitUrl); + } catch { + return false; + } + if (url.hostname !== 'github.com') { + return false; + } + const repoPath = url.pathname + .replace(/^\//, '') + .replace(/\.git$/, '') + .replace(/\/$/, ''); + return repoPath === 'AztecProtocol/aztec-nr'; +} + +/** Warns if any aztec-nr git dependency in a crate's Nargo.toml has a tag that doesn't match the CLI version. */ export async function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string): Promise { const version = cliVersion ?? getPackageVersion(); if (!version) { @@ -16,7 +34,7 @@ export async function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string } const expectedTag = `v${version}`; - const mismatches: { file: string; tag: string }[] = []; + const mismatches: { file: string; depName: string; tag: string }[] = []; const crateDirs = await collectCrateDirs('.', { skipGitDeps: true }); @@ -30,23 +48,28 @@ export async function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string } const parsed = TOML.parse(content) as Record; - const aztecDep = (parsed.dependencies as Record)?.aztec; - if (!aztecDep || typeof aztecDep !== 'object' || typeof aztecDep.tag !== 'string') { - // If a dep called "aztec" doesn't exist or it does not get parsed to an object or it doesn't have a tag defined - // we skip the check. - continue; - } + const deps = (parsed.dependencies as Record) ?? {}; - if (aztecDep.tag !== expectedTag) { - mismatches.push({ file: tomlPath, tag: aztecDep.tag }); + for (const [depName, dep] of Object.entries(deps)) { + // Skip non-object deps (e.g. malformed entries) and anything that isn't a tagged git dep. + if (!dep || typeof dep !== 'object' || typeof dep.git !== 'string' || typeof dep.tag !== 'string') { + continue; + } + // Only flag deps that are sourced from the aztec-nr repo. + if (!isAztecNrGitUrl(dep.git)) { + continue; + } + if (dep.tag !== expectedTag) { + mismatches.push({ file: tomlPath, depName, tag: dep.tag }); + } } } if (mismatches.length > 0) { - const details = mismatches.map(m => ` ${m.file} (${m.tag})`).join('\n'); + const details = mismatches.map(m => ` ${m.file} — ${m.depName} (${m.tag})`).join('\n'); log( `WARNING: Aztec dependency version mismatch detected.\n` + - `The following crates have an aztec dependency that does not match the CLI version (${expectedTag}):\n` + + `The following aztec-nr dependencies do not match the CLI version (${expectedTag}):\n` + `${details}\n\n` + `See https://docs.aztec.network/errors/9 for how to update your dependencies.`, );