From 13f94f2cde94d59f607610ffc788dd21ce2f3a49 Mon Sep 17 00:00:00 2001 From: Yaniv Tanenzapf Date: Tue, 7 Jul 2026 11:52:36 +0300 Subject: [PATCH] Revert "AX-1792: Remove JFROG_URL validation from SessionStart injector (#30)" This reverts commit 7f8e0690a918914c75e18ab2514c744547abc45c. --- plugin/scripts/inject-instructions.mjs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/plugin/scripts/inject-instructions.mjs b/plugin/scripts/inject-instructions.mjs index a159190..1539b52 100644 --- a/plugin/scripts/inject-instructions.mjs +++ b/plugin/scripts/inject-instructions.mjs @@ -114,6 +114,30 @@ if (forceDisabled) { process.exit(0); } +// Validate JFROG_URL early to surface misconfigurations before the MCP server +// attempts to connect and fails with a confusing DNS or double-slash error. +if (!process.env.JFROG_URL) { + const missingUrlWarning = "WARNING: JFROG_URL is not set. The JFrog MCP server will be unreachable — set JFROG_URL to your Artifactory base URL (e.g. https://mycompany.jfrog.io) and restart."; + log(missingUrlWarning); + process.stdout.write(JSON.stringify({ + hookSpecificOutput: { + hookEventName: "SessionStart", + additionalContext: `IMPORTANT: Immediately tell the user: "${missingUrlWarning}"`, + }, + })); + process.exit(0); +} else if (process.env.JFROG_URL.endsWith("/")) { + const trailingSlashWarning = "WARNING: JFROG_URL has a trailing slash. This produces a double-slash in the MCP URL and will silently fail — remove the trailing slash and restart."; + log(trailingSlashWarning); + process.stdout.write(JSON.stringify({ + hookSpecificOutput: { + hookEventName: "SessionStart", + additionalContext: `IMPORTANT: Immediately tell the user: "${trailingSlashWarning}"`, + }, + })); + process.exit(0); +} + if (forceEnabled) { debug("Force-enable flag is set."); } else if (!(await isAgentGuardEnabledViaSettings())) {