pinpoint-apm/pinpoint · error · ResponseStatusException

Invalid serviceTypeName

Error message

Invalid serviceTypeName 

What it means

ApplicationValidator.newApplication(name, serviceTypeName) throws a 400 ResponseStatusException when serviceTypeName is null/empty (StringUtils.hasLength fails). It rejects the request before consulting the service type registry.

Source

Thrown at web/src/main/java/com/navercorp/pinpoint/web/util/ApplicationValidator.java:43

    public ApplicationValidator(ServiceTypeRegistryService registry, int undefined) {
        this.registry = Objects.requireNonNull(registry, "registry");
        this.undefined = undefined;
    }

    public Application newApplication(String applicationName, int serviceTypeCode) {
        validateName(applicationName);
        if (serviceTypeCode == undefined) {
            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid serviceTypeCode" + serviceTypeCode);
        }
        ServiceType serviceType = registry.findServiceType(serviceTypeCode);
        return new Application(applicationName, serviceType);
    }

    public Application newApplication(String applicationName, String serviceTypeName) {
        validateName(applicationName);
        if (!StringUtils.hasLength(serviceTypeName)) {
            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid serviceTypeName " + serviceTypeName);
        }
        ServiceType serviceType = registry.findServiceTypeByName(serviceTypeName);
        if (serviceType.getCode() == undefined) {
            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid serviceTypeName " + serviceTypeName);
        }
        return new Application(applicationName, serviceType);
    }

    public Application newApplication(String applicationName, int serviceTypeCode, String serviceTypeName) {
        return newApplication(Service.DEFAULT, applicationName, serviceTypeCode, serviceTypeName);
    }

    public Application newApplication(Service service, String applicationName, int serviceTypeCode, String serviceTypeName) {
        Objects.requireNonNull(service, "service");
        validateName(applicationName);

        ServiceType serviceType = null;
        if (serviceTypeCode != undefined) {

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Provide a valid serviceTypeName (e.g. STAND_ALONE, TOMCAT) in the request/config
  2. Print/log the source of the value (env var, config file) and fix the empty source
  3. Use the serviceTypeCode-based overload if you know the numeric code instead
  4. Verify case-sensitive spelling against GET /serviceTypeInfo

Example fix

// before
newApplication("myApp", "")
// after
newApplication("myApp", "STAND_ALONE")
Defensive patterns

Strategy: validation

Validate before calling

if (!serviceTypeName || serviceTypeName.trim().length === 0) {
  throw new Error('serviceTypeName must be a non-empty string');
}

Type guard

function hasServiceTypeName(v) {
  return typeof v === 'string' && v.trim().length > 0;
}

Try / catch

try {
  const app = newApplication(name, serviceTypeName);
} catch (e) {
  if (e instanceof ResponseStatusException && e.getMessage().contains('Invalid serviceTypeName')) {
    // supply a default type or abort config load
  }
  throw e;
}

Prevention

When it happens

Trigger: Building/POSTing an Application with serviceTypeName missing, empty string, or whitespace-only value; the empty check runs before name lookup, so this fires even before the undefined-code check on the same message.

Common situations: Config where the service type name is pulled from an env var or properties file that is unset/blank; JSON payloads omitting the field; scripts quoting an empty variable.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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