{"record":{"id":"7f3f1d34f9013c53","repo":"pinpoint-apm/pinpoint","slug":"invalid-servicetypecode-or-servicetypename","errorCode":null,"errorMessage":"Invalid serviceTypeCode or serviceTypeName","messagePattern":"Invalid serviceTypeCode or serviceTypeName","errorType":"validation","errorClass":"ResponseStatusException","httpStatus":400,"severity":"error","filePath":"web/src/main/java/com/navercorp/pinpoint/web/util/ApplicationValidator.java","lineNumber":71,"sourceCode":"        return newApplication(Service.DEFAULT, applicationName, serviceTypeCode, serviceTypeName);\n    }\n\n    public Application newApplication(Service service, String applicationName, int serviceTypeCode, String serviceTypeName) {\n        Objects.requireNonNull(service, \"service\");\n        validateName(applicationName);\n\n        ServiceType serviceType = null;\n        if (serviceTypeCode != undefined) {\n            serviceType = registry.findServiceType(serviceTypeCode);\n        }\n        if (StringUtils.hasLength(serviceTypeName)) {\n            serviceType = registry.findServiceTypeByName(serviceTypeName);\n        }\n        if (serviceType != null && serviceType.getCode() != undefined) {\n            return new Application(service, applicationName, serviceType);\n        }\n\n        throw new ResponseStatusException(HttpStatus.BAD_REQUEST, \"Invalid serviceTypeCode or serviceTypeName\");\n    }\n\n    public void validateName(String applicationName) {\n        if (!StringUtils.hasLength(applicationName) || !IdValidateUtils.validateId(applicationName, MAX_LENGTH)) {\n            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, \"Invalid applicationName \" + applicationName);\n        }\n    }\n}\n","sourceCodeStart":53,"sourceCodeEnd":80,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/web/src/main/java/com/navercorp/pinpoint/web/util/ApplicationValidator.java#L53-L80","documentation":"The combined overload ApplicationValidator.newApplication(service, name, serviceTypeCode, serviceTypeName) tries to resolve the ServiceType by code, then by name; if both fail (null or undefined code) it throws a 400 ResponseStatusException 'Invalid serviceTypeCode or serviceTypeName'. Neither identifier could be matched to a registered service type.","triggerScenarios":"Calling the 4-arg overload where serviceTypeCode is the undefined sentinel AND serviceTypeName is empty/unknown — e.g. both fields defaulted, or code 0 with an unrecognized name.","commonSituations":"Client config where both serviceType settings were never filled in; migrating configs between environments where neither the code nor the name exists in the target Pinpoint; serialized payloads with zero-value defaults for both fields.","solutions":["Fill in at least one valid identifier: a real serviceTypeCode or a registered serviceTypeName","Verify valid values via GET /serviceTypeInfo","Fix config/serialization that defaults both fields to 0/null (e.g. missing YAML keys)","If both are provided, ensure they refer to the same ServiceType"],"exampleFix":"// before\nnewApplication(\"DEFAULT\", \"myApp\", 0, null)\n// after\nnewApplication(\"DEFAULT\", \"myApp\", 1010, \"STAND_ALONE\")","handlingStrategy":"validation","validationCode":"// Ensure at least one valid identifier before calling the combined overload\nconst valid = (code !== undefinedCode) || (name && knownTypes.includes(name));\nif (!valid) throw new Error('Provide a valid serviceTypeCode or serviceTypeName');","typeGuard":"function hasValidServiceType(code, undefinedCode, name, knownTypes) {\n  return (Number.isInteger(code) && code !== undefinedCode) ||\n         (typeof name === 'string' && knownTypes.includes(name));\n}","tryCatchPattern":"try {\n  const app = newApplication(service, name, code, typeName);\n} catch (e) {\n  if (e instanceof ResponseStatusException && e.getMessage().includes('Invalid serviceTypeCode or serviceTypeName')) {\n    // fix config then retry\n  }\n  throw e;\n}","preventionTips":["Never leave both serviceTypeCode and serviceTypeName unset in configs","Validate config at load time against /serviceTypeInfo","When both are given, ensure they match the same ServiceType","Avoid serializing zero-value defaults for both fields"],"tags":["http-400","service-type","validation","config"],"backgroundTag":"invalid-argument-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"}