Skip to content

fix(cli): validate Java before downloading server JAR (#258)#264

Open
vovaparker wants to merge 4 commits into
agentspan-ai:mainfrom
vovaparker:fix/cli-validate-java-before-jar-258
Open

fix(cli): validate Java before downloading server JAR (#258)#264
vovaparker wants to merge 4 commits into
agentspan-ai:mainfrom
vovaparker:fix/cli-validate-java-before-jar-258

Conversation

@vovaparker

@vovaparker vovaparker commented May 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #258.

agentspan server start currently downloads the ~307 MB server JAR before validating that a compatible Java is available. If Java is missing or too old, the user waits through a multi-minute download only to be told the install can't proceed.

This PR moves the Java check to the top of runServerStart.

What changed

  • serverCheckJava() block moved to the very top of runServerStart, before os.MkdirAll(dir) and the JAR resolution branches.
  • Extracted JVM-launch logic into a new launchServer. This lets the test run runServerStart end-to-end without launching a real JVM.

Tests

Two tests in cli/cmd/server_test.go:

  • TestServerStartUsesRequestedVersion (existing, updated): previously used checkJava = false to halt execution, which encoded the bug. Now uses serverLaunch fake to halt before the real JVM launches.
  • TestServerStartFailsWhenJavaMissing (new): ordering test. With Java missing, asserts that none of ensureLatestJAR, ensureVersionedJAR, findLocalJAR, or launchServer is reached, and that the error message mentions Java. Catches the bug this PR fixes.

vovaparker and others added 2 commits May 21, 2026 22:53
Move serverCheckJava() to the top of runServerStart so the user
fails fast with a clear error instead of waiting through a
307 MB JAR download they can't use.

Extract the inline JVM-launch block into launchServer, held in a
package var (serverLaunch) so tests can stub it. This lets the
new ordering test run runServerStart end-to-end without launching
a real JVM.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Java validation has no dependency on the server data dir existing,
so run it first — fail fast without even creating ~/.agentspan/server/
when we know we can't proceed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vovaparker

Copy link
Copy Markdown
Contributor Author

Thanks for approving it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

server start downloads 307 MB JAR before checking Java version

2 participants