pinpoint-apm/pinpoint · error · IllegalArgumentException

invalid =

Error message

invalid ${KEY_CONTAINER_ID}=${containerId}

What it means

toContainerAgentAuth converts a container.id attribute into an AgentAuth. It tries the 64-hex Docker SHA256 path (truncating to a Base64 agentId) and otherwise validates the raw containerId as a plain agentId; failure of IdValidateUtils (AGENT_ID_MAX_LEN) throws this IllegalArgumentException naming the container-id key.

Solutions

  1. Provide the full 64-char lowercase hex container ID (docker inspect --format '{{.Id}}')
  2. Prefer service.instance.id=$(uuidgen) as the per-instance identifier instead
  3. Attach an explicit valid pinpoint.agentId attribute to bypass container-id parsing
  4. Verify the container runtime exports IDs in the expected hex format

Example fix

// before
attributes.put("container.id", "my_container");
// after
attributes.put("container.id", "a1b2c3...64-hex-chars");
Defensive patterns

Strategy: validation

Validate before calling

if (containerId != null && !containerId.matches("[0-9a-f]{64}") && !IdValidateUtils.validateId(containerId, PinpointConstants.AGENT_ID_MAX_LEN)) {
    throw new IllegalArgumentException("invalid container.id=" + containerId);
}

Type guard

boolean isDockerContainerId(String id) { return id != null && id.matches("[0-9a-f]{64}"); }

Prevention

When it happens

Trigger: A container.id attribute value that is neither a 64-char hex Docker ID nor a value passing validateId — e.g. a pod-UID-style UUID with hyphens, a container name with invalid chars, or a truncated/odd-length hex string.

Common situations: CRI runtimes exposing pod UIDs instead of Docker container IDs; manual config using container names with underscores; version changes where container IDs are no longer 64-hex (e.g. some containerd/Podman setups).

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07). Data as JSON: /api/errors/3c72c9a36dba6c16. Report an issue: GitHub.

Appendix: source

Thrown at otlptrace/otlptrace-collector/src/main/java/com/navercorp/pinpoint/otlp/trace/collector/mapper/OtlpTraceMapperUtils.java:217

            throw new IllegalArgumentException("invalid " + sourceKey + "=" + id);
        }
        return new AgentAuth(id, resolveAgentName(agentNameOverride, id));
    }

    private static AgentAuth toContainerAgentAuth(String containerId, String agentNameOverride) {
        // Docker/containerd full ID: 64 lowercase hex chars (SHA256).
        // Truncate to first 16 bytes → 22-char URL-safe Base64 (same format as UUID case).
        if (containerId.length() == CONTAINER_ID_FULL_HEX_LEN) {
            try {
                final byte[] bytes = Base16Utils.decodeToBytes(containerId);
                final byte[] prefix = Arrays.copyOf(bytes, AGENT_ID_HASH_PREFIX_BYTES);
                return new AgentAuth(Base64Utils.encode(prefix), resolveAgentName(agentNameOverride, containerId));
            } catch (IllegalArgumentException ignore) {
                // not valid hex, fall through to treat as plain agentId
            }
        }
        if (!IdValidateUtils.validateId(containerId, PinpointConstants.AGENT_ID_MAX_LEN)) {
            throw new IllegalArgumentException("invalid " + KEY_CONTAINER_ID + "=" + containerId);
        }
        return new AgentAuth(containerId, resolveAgentName(agentNameOverride, containerId));
    }

    public static String getServiceName(Map<String, AttributeValue> attributes) {
        // TEMPORARY: OTLP spans are always assigned the DEFAULT serviceName, matching the native
        // agent's effective default (SpanOwner.serviceName = ServiceUid.DEFAULT_SERVICE_UID_NAME).
        // Rationale: OTLP applications are registered under DEFAULT_SERVICE_UID (see
        // OtlpTraceExportService), and the web queries service-keyed stores (e.g. the Pinot heatmap
        // sortKey = serviceName#applicationName) with DEFAULT. Deriving serviceName from
        // pinpoint.serviceName / service.namespace here produced a key that never matched the web
        // query, so OTLP transactions were missing from those views.
        // Revisit once the serviceUid policy for OTLP is decided; the attribute-based resolution
        // below should be restored (and validated against DEFAULT_SERVICE_UID registration) then.
        //
        //   String serviceName = AttributeUtils.getAttributeStringValue(attributes, KEY_PINPOINT_SERVICE_NAME, null);
        //   if (serviceName == null) {
        //       serviceName = AttributeUtils.getAttributeStringValue(attributes, KEY_SERVICE_NAMESPACE, null);

View on GitHub (pinned to 744c3d3075)