{"record":{"id":"67cb2b9535ada0da","repo":"pinpoint-apm/pinpoint","slug":"length-range-is-1-24","errorCode":null,"errorMessage":"length range is 1 ~ 24","messagePattern":"length range is 1 ~ 24","errorType":"http","errorClass":"ResponseStatusException","httpStatus":400,"severity":"warning","filePath":"web/src/main/java/com/navercorp/pinpoint/web/authorization/controller/AgentInfoController.java","lineNumber":185,"sourceCode":"    @PreAuthorize(\"@naverPermissionEvaluator.hasInspectorPermission(#serviceName.getName(), new com.navercorp.pinpoint.common.server.bo.AgentParam(#agentId, #to))\")\n    @GetMapping(value = \"/getAgentStatusTimeline\", params = {\"exclude\"})\n    public InspectorTimeline getAgentStatusTimeline(\n            @ServiceParam ServiceName serviceName,\n            @RequestParam(\"applicationName\") @NotBlank String applicationName,\n            @RequestParam(\"agentId\") @NotBlank String agentId,\n            @RequestParam(\"from\") Timestamp from,\n            @RequestParam(\"to\") Timestamp to,\n            @RequestParam(value = \"exclude\", defaultValue = \"\") int[] excludeEventTypeCodes) {\n        final Range range = Range.between(from, to);\n        rangeValidator.validate(range);\n        return agentInfoService.getAgentStatusTimeline(serviceName.getName(), applicationName, agentId, range, excludeEventTypeCodes);\n    }\n\n    @RequestMapping(value = \"/isAvailableAgentId\")\n    public CodeResult<String> isAvailableAgentId(@ServiceParam ServiceName serviceName, @RequestParam(\"agentId\") @NotBlank String agentId) {\n        final IdValidateUtils.CheckResult result = IdValidateUtils.checkId(agentId, PinpointConstants.AGENT_ID_MAX_LEN);\n        if (result == IdValidateUtils.CheckResult.FAIL_LENGTH) {\n            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, \"length range is 1 ~ 24\");\n        }\n        if (result == IdValidateUtils.CheckResult.FAIL_PATTERN) {\n            throw new ResponseStatusException(\n                    HttpStatus.BAD_REQUEST,\n                    \"invalid pattern(\" + IdValidateUtils.ID_PATTERN_VALUE + \")\"\n            );\n        }\n        if (agentInfoService.findAgentInfo(agentId, System.currentTimeMillis()) != null) {\n            throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, \"agentId already exists\");\n        }\n        return CodeResult.ok(\"OK\");\n    }\n\n}\n","sourceCodeStart":167,"sourceCodeEnd":200,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/web/src/main/java/com/navercorp/pinpoint/web/authorization/controller/AgentInfoController.java#L167-L200","documentation":"AgentInfoController.isAvailableAgentId validates a candidate agentId against Pinpoint's agent-id length constraint (1..AGENT_ID_MAX_LEN=24). A FAIL_LENGTH result throws HTTP 400 'length range is 1 ~ 24'.","triggerScenarios":"GET /isAvailableAgentId?agentId=<empty-after-blank-check-or->24-chars> — the id is longer than 24 characters (empty is caught earlier by @NotBlank).","commonSituations":"Programmatically generated agent ids (hostnames + suffixes) exceeding 24 chars; UUIDs used as agent ids; trailing whitespace pushing length over the limit.","solutions":["Shorten the agentId to 24 characters or fewer (and at least 1)","Truncate or hash long hostnames when generating agent ids in the agent config","Pre-validate length in the client before calling"],"exampleFix":"// before\nString agentId = hostname + \"-\" + app; // often > 24 chars\n// after\nString agentId = (hostname + \"-\" + app).substring(0, Math.min(24, hostname.length() + 1 + app.length()));","handlingStrategy":"validation","validationCode":"if (agentId == null || agentId.isEmpty() || agentId.length() > 24) throw new IllegalArgumentException(\"agentId length must be 1~24\");","typeGuard":"boolean isValidAgentIdLength(String id) { return id != null && !id.isEmpty() && id.length() <= PinpointConstants.AGENT_ID_MAX_LEN; }","tryCatchPattern":"try { return api.isAvailableAgentId(id); } catch (ResponseStatusException e) { if (e.getStatus() == HttpStatus.BAD_REQUEST) return \"RETRY_WITH_NEW_ID\"; throw e; }","preventionTips":["Enforce the 1-24 char limit wherever agent ids are generated","Avoid raw hostnames/UUIDs as agent ids without truncation","Call isAvailableAgentId before registering a new agent"],"tags":["http-400","validation","identifier","length-limit"],"backgroundTag":"invalid-identifier-format","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}