pinpoint-apm/pinpoint · error · ResponseStatusException

Invalid serviceTypeCode or serviceTypeName

Error message

Invalid serviceTypeCode or serviceTypeName

What it means

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.

Source

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

        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) {
            serviceType = registry.findServiceType(serviceTypeCode);
        }
        if (StringUtils.hasLength(serviceTypeName)) {
            serviceType = registry.findServiceTypeByName(serviceTypeName);
        }
        if (serviceType != null && serviceType.getCode() != undefined) {
            return new Application(service, applicationName, serviceType);
        }

        throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid serviceTypeCode or serviceTypeName");
    }

    public void validateName(String applicationName) {
        if (!StringUtils.hasLength(applicationName) || !IdValidateUtils.validateId(applicationName, MAX_LENGTH)) {
            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid applicationName " + applicationName);
        }
    }
}

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Fill in at least one valid identifier: a real serviceTypeCode or a registered serviceTypeName
  2. Verify valid values via GET /serviceTypeInfo
  3. Fix config/serialization that defaults both fields to 0/null (e.g. missing YAML keys)
  4. If both are provided, ensure they refer to the same ServiceType

Example fix

// before
newApplication("DEFAULT", "myApp", 0, null)
// after
newApplication("DEFAULT", "myApp", 1010, "STAND_ALONE")
Defensive patterns

Strategy: validation

Validate before calling

// Ensure at least one valid identifier before calling the combined overload
const valid = (code !== undefinedCode) || (name && knownTypes.includes(name));
if (!valid) throw new Error('Provide a valid serviceTypeCode or serviceTypeName');

Type guard

function hasValidServiceType(code, undefinedCode, name, knownTypes) {
  return (Number.isInteger(code) && code !== undefinedCode) ||
         (typeof name === 'string' && knownTypes.includes(name));
}

Try / catch

try {
  const app = newApplication(service, name, code, typeName);
} catch (e) {
  if (e instanceof ResponseStatusException && e.getMessage().includes('Invalid serviceTypeCode or serviceTypeName')) {
    // fix config then retry
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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