pinpoint-apm/pinpoint · error · ResponseStatusException

Undefined service type

Error message

Undefined service type

What it means

AdminController.removeApplication resolves the application's ServiceType from the provided serviceTypeCode or serviceTypeName via the application factory. If neither is supplied (or they don't match a known service type), the resolved Application has ServiceType.UNDEFINED and the controller rejects the request with HTTP 400 'Undefined service type'. The admin delete APIs require an explicit, resolvable service type.

Source

Thrown at web/src/main/java/com/navercorp/pinpoint/web/authorization/controller/AdminController.java:90

        logger.info("Removing application - applicationName: [{}]", applicationName);
        try {
            this.adminService.removeApplicationName(applicationName);
            return "OK";
        } catch (Exception e) {
            logger.error("error while removing applicationName", e);
            throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());
        }
    }

    @DeleteMapping(value = "/applications")
    public String removeApplication(@ServiceParam ServiceName serviceName,
                                    @RequestParam("applicationName") @NotBlank String applicationName,
                                    @RequestParam(value = "serviceTypeCode", required = false) Integer serviceTypeCode,
                                    @RequestParam(value = "serviceTypeName", required = false) String serviceTypeName) {
        Service service = serviceModelResolver.getService(serviceName.getName());
        Application application = getApplication(service, applicationName, serviceTypeCode, serviceTypeName);
        if (application.getServiceType().equals(ServiceType.UNDEFINED)) {
            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Undefined service type");
        }
        logger.info("Removing application - application: {}", application);
        try {
            this.adminService.removeApplication(application.getService(), application.getApplicationName(), application.getServiceTypeCode());
            return "OK";
        } catch (Exception e) {
            logger.error("error while removing application", e);
            throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());
        }
    }

    @Deprecated
    @RequestMapping(value = "/removeAgentId", params = {"!serviceTypeCode", "!serviceTypeName"})
    public String removeAgentId(
            @RequestParam(value = "applicationName") @NotBlank String applicationName,
            @RequestParam(value = "agentId") @NotBlank String agentId
    ) {
        logger.info("Removing agent - applicationName: [{}], agentId: [{}]", applicationName, agentId);

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Pass a resolvable service type: add either serviceTypeCode (e.g. 1010) or serviceTypeName (e.g. TOMCAT) matching the application
  2. Get the exact code/name from the Pinpoint UI inspector or the service-types registry to avoid case/spelling mismatch
  3. If the type is custom, register its descriptor in Web's service type configuration so it stops resolving to UNDEFINED
  4. If you intentionally want the legacy behavior, use the deprecated /admin/removeApplication endpoint (though supplying the type is safer)

Example fix

// before
DELETE /admin/applications?applicationName=MyApp            -> 400 Undefined service type
// after
DELETE /admin/applications?applicationName=MyApp&serviceTypeName=TOMCAT
Defensive patterns

Strategy: validation

Validate before calling

if (serviceTypeCode == null && !serviceTypeName) {
  throw new Error('Either serviceTypeCode or serviceTypeName is required');
}

Try / catch

try {
  await adminApi.removeApplication({ applicationName, serviceTypeName });
} catch (e) {
  if (e.status === 400 && String(e.message).includes('Undefined service type')) {
    throw new Error('Supply a valid serviceTypeCode/serviceTypeName, e.g. TOMCAT (1010)');
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling the /applications DELETE endpoint without serviceTypeCode and without serviceTypeName, or with a code/name that does not map to a registered ServiceType — e.g. serviceTypeName=UNKNOWN_APP or an unregistered code.

Common situations: Calling the newer @DeleteMapping API but porting only the old parameters (applicationName only, as the deprecated endpoint allowed); misspelling the service type name; case differences; the service type exists in the agent but is not registered in Web's serviceType registry (missing typescript/properties in service-type descriptors).

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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