{"record":{"id":"e8844120d5dddcc0","repo":"pinpoint-apm/pinpoint","slug":"invalid-servicetypecode","errorCode":null,"errorMessage":"Invalid serviceTypeCode","messagePattern":"Invalid serviceTypeCode","errorType":"validation","errorClass":"ResponseStatusException","httpStatus":400,"severity":"error","filePath":"web/src/main/java/com/navercorp/pinpoint/web/util/ApplicationValidator.java","lineNumber":34,"sourceCode":"    static final int UNDEFINED = ServiceType.UNDEFINED.getCode();\n    static final int MAX_LENGTH = PinpointConstants.AGENT_NAME_MAX_LEN;\n\n    private final ServiceTypeRegistryService registry;\n    private final int undefined;\n\n    public ApplicationValidator(ServiceTypeRegistryService registry) {\n        this(registry, UNDEFINED);\n    }\n\n    public ApplicationValidator(ServiceTypeRegistryService registry, int undefined) {\n        this.registry = Objects.requireNonNull(registry, \"registry\");\n        this.undefined = undefined;\n    }\n\n    public Application newApplication(String applicationName, int serviceTypeCode) {\n        validateName(applicationName);\n        if (serviceTypeCode == undefined) {\n            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, \"Invalid serviceTypeCode\" + serviceTypeCode);\n        }\n        ServiceType serviceType = registry.findServiceType(serviceTypeCode);\n        return new Application(applicationName, serviceType);\n    }\n\n    public Application newApplication(String applicationName, String serviceTypeName) {\n        validateName(applicationName);\n        if (!StringUtils.hasLength(serviceTypeName)) {\n            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, \"Invalid serviceTypeName \" + serviceTypeName);\n        }\n        ServiceType serviceType = registry.findServiceTypeByName(serviceTypeName);\n        if (serviceType.getCode() == undefined) {\n            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, \"Invalid serviceTypeName \" + serviceTypeName);\n        }\n        return new Application(applicationName, serviceType);\n    }\n\n    public Application newApplication(String applicationName, int serviceTypeCode, String serviceTypeName) {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/web/src/main/java/com/navercorp/pinpoint/web/util/ApplicationValidator.java#L16-L52","documentation":"ApplicationValidator.newApplication(name, serviceTypeCode) throws a 400 ResponseStatusException when the supplied serviceTypeCode equals the registry's 'undefined' code, meaning no real ServiceType was identified. The application cannot be registered without a valid service type.","triggerScenarios":"Calling an API that builds an Application from a numeric serviceTypeCode (e.g. POST /application) passing the sentinel undefined code (typically 0 or an unknown value) instead of a registered ServiceType code.","commonSituations":"Clients sending serviceTypeCode=0 or a default/uninitialized value; agent/plugin config where the service type code was changed and the old code is now undefined; copy-pasted sample payloads with placeholder codes.","solutions":["Look up the correct serviceTypeCode from Pinpoint's ServiceType list (GET /serviceTypeInfo) and resend","If you only know the type name, use the variant accepting serviceTypeName instead","Check plugin/agent config that supplies the code for stale or default (0) values","Update client code that hardcodes the code after a Pinpoint version upgrade changed the registry"],"exampleFix":"// before\nnewApplication(\"myApp\", 0) // 0 = undefined\n// after\nnewApplication(\"myApp\", 1010) // e.g. STAND_ALONE code from serviceTypeInfo","handlingStrategy":"validation","validationCode":"// Resolve a valid serviceTypeCode before building the application\nconst types = (await axios.get('/serviceTypeInfo')).data;\nconst code = 1010; // desired code\nif (!types.some(t => t.code === code)) {\n  throw new Error(`serviceTypeCode ${code} not registered`);\n}","typeGuard":"function isDefinedCode(code, undefinedCode) {\n  return Number.isInteger(code) && code !== undefinedCode && code > 0;\n}","tryCatchPattern":"try {\n  const app = newApplication(name, serviceTypeCode);\n} catch (e) {\n  if (e instanceof ResponseStatusException && e.getMessage().startsWith('Invalid serviceTypeCode')) {\n    // fall back to name-based lookup or fix the code\n  }\n  throw e;\n}","preventionTips":["Fetch /serviceTypeInfo to pick valid codes instead of hardcoding","Never pass 0 or uninitialized ints as serviceTypeCode","Prefer the serviceTypeName overload when the code is unknown","Re-check codes after Pinpoint upgrades or plugin changes"],"tags":["http-400","service-type","validation","rest-api"],"backgroundTag":"invalid-enum-value","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"}