pinpoint-apm/pinpoint · warning · ResponseStatusException
invalid pattern([a-zA-Z0-9._\-]+)
Error message
invalid pattern([a-zA-Z0-9._\-]+)
What it means
isAvailableAgentId also checks the agentId character pattern via IdValidateUtils; a FAIL_PATTERN result throws HTTP 400 'invalid pattern([a-zA-Z0-9._\-]+)'. Only alphanumerics, dot, underscore, and hyphen are allowed.
Source
Thrown at web/src/main/java/com/navercorp/pinpoint/web/authorization/controller/AgentInfoController.java:188
@ServiceParam ServiceName serviceName,
@RequestParam("applicationName") @NotBlank String applicationName,
@RequestParam("agentId") @NotBlank String agentId,
@RequestParam("from") Timestamp from,
@RequestParam("to") Timestamp to,
@RequestParam(value = "exclude", defaultValue = "") int[] excludeEventTypeCodes) {
final Range range = Range.between(from, to);
rangeValidator.validate(range);
return agentInfoService.getAgentStatusTimeline(serviceName.getName(), applicationName, agentId, range, excludeEventTypeCodes);
}
@RequestMapping(value = "/isAvailableAgentId")
public CodeResult<String> isAvailableAgentId(@ServiceParam ServiceName serviceName, @RequestParam("agentId") @NotBlank String agentId) {
final IdValidateUtils.CheckResult result = IdValidateUtils.checkId(agentId, PinpointConstants.AGENT_ID_MAX_LEN);
if (result == IdValidateUtils.CheckResult.FAIL_LENGTH) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "length range is 1 ~ 24");
}
if (result == IdValidateUtils.CheckResult.FAIL_PATTERN) {
throw new ResponseStatusException(
HttpStatus.BAD_REQUEST,
"invalid pattern(" + IdValidateUtils.ID_PATTERN_VALUE + ")"
);
}
if (agentInfoService.findAgentInfo(agentId, System.currentTimeMillis()) != null) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "agentId already exists");
}
return CodeResult.ok("OK");
}
}
View on GitHub (pinned to 744c3d3075)
Solutions
- Remove/replace illegal characters with '-', '_', or '.'
- Sanitize/normalize the id on the agent side before registration
- Pre-validate with regex ^[a-zA-Z0-9._\-]+$ in the client
Example fix
// before
String agentId = "my host:8080";
// after
String agentId = "my-host-8080".replaceAll("[^a-zA-Z0-9._\\-]", "-"); Defensive patterns
Strategy: validation
Validate before calling
if (!agentId.matches("^[a-zA-Z0-9._\\-]+$")) throw new IllegalArgumentException("agentId must match [a-zA-Z0-9._\\-]+"); Type guard
boolean isValidAgentIdPattern(String id) { return id != null && id.matches("[a-zA-Z0-9._\\-]+"); } Try / catch
try { return api.isAvailableAgentId(id); } catch (ResponseStatusException e) { if (e.getStatus() == HttpStatus.BAD_REQUEST) { log.warn("invalid agentId pattern: {}", id); return null; } throw e; } Prevention
- Sanitize agent ids with replaceAll("[^a-zA-Z0-9._\\-]", "-") at generation time
- Never build agent ids from raw user input or host:port strings
- Share one validation regex between agent config and client tooling
When it happens
Trigger: GET /isAvailableAgentId with an agentId containing characters outside [a-zA-Z0-9._-], e.g. spaces, colons, slashes, or non-ASCII characters.
Common situations: Using FQDNs with ports ('host:8080') or paths as agent ids; non-ASCII hostnames; ids derived from user input without sanitization.
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
- length range is 1 ~ 24
- Invalid applicationName
- sqlUid length must be 16: ${sqlUid.length}
- invalid applicationName=${applicationName}
- invalid ${sourceKey}=${id}
AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07).
Data as JSON: /api/errors/b5cc4ad1f601e8dc.
Report an issue: GitHub.