Repository navigation
feat(agent): detect the guard-core-jvm version at runtime when unset - #17
Merged
Merged
Conversation
Contributor
|
Thanks for opening your first pull request on guard-agent-jvm! Quick checklist before review (most of these are enforced by CI, but worth a glance):
See README.md for the agent status. Welcome aboard - a maintainer will review shortly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Java projects never reported their engine version. The agent sends
guard_core_versiononly whenAgentConfig.guardCoreVersionis set (Transport.kt:201/251), the default is empty (AgentConfig.kt:248), and the adapters take a user-built agent, so nothing ever filled it. As a result the SaaS could never flag an outdated engine for a Java project.This ports the Go agent's behavior (agent.go:183-186, version.go:24-38): when the config leaves the version empty,
GuardAgent.createfills it fromcom.guardcore.engine.GuardCoreEngine.VERSION. The value is read by reflection at runtime, because the engine is a compile-only dependency that may be absent, and a direct reference to theconst valwould inline the compile-time version. A user-set value always wins, and a missing engine yields "" without throwing.Tests:
GuardCoreVersionTestcovers the engine version being filled in, a user value winning, and a missing class giving "".CoverageMoreTest.settleMetricsNilErrorAfterFailedSplitraises its mock body cap from 320 to 350 bytes, because every batch now carries the version field. Recorded with the mock's call log, master at 320 and this branch at 350 produce the identical call sequence [413, 413, 500, 500, 413, 200, 200], so the test exercises exactly the same path.Local gate:
./gradlew buildpasses, with 199 tests and 0 failures.Release: this lands on master only. Agents release in lockstep, so it ships with the next agent train (3.2.4 across all families).