Skip to content

Issue in refreshMajorServerVersion: Incorrect Server Version Check URL Handling with Path Prefixes #1724

@fangwentong

Description

@fangwentong

Description
The refreshMajorServerVersion method in HTTPTransport currently constructs an incorrect URL when fetching APM Server version information. The implementation ignores any path prefix configured in the APM Server URL, resulting in requests to the server root path instead of the configured endpoint.

Steps to Reproduce

  1. Configure APM Server URL with a path prefix (e.g., https://example.com/apm_server)
  2. Agent attempts to check server version during initialization
  3. Observe the actual request URL being made to https://example.com/ instead of https://example.com/apm_server

Expected Behavior
The version check request should preserve the path prefix from the configured APM Server URL.
For configuration https://example.com/apm_server, the request should be sent to https://example.com/apm_server/.

Actual Behavior
The current implementation strips all path components and sends requests to the server root:

u := *srvURL
u.Path, u.RawPath = "", ""  // This discards any existing path
urlWithPath(&u, "/")        // Forces root path

Code Reference
Relevant code in http_transport.go:

func (t *HTTPTransport) refreshMajorServerVersion(ctx context.Context) uint32 {
    srvURL := t.intakeURLs[atomic.LoadInt32(&t.urlIndex)]
    u := *srvURL
    u.Path, u.RawPath = "", "" // Problematic line
    req := requestWithContext(ctx, t.newRequest("GET", urlWithPath(&u, "/")))
    // ... rest of implementation ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions