pinpoint-apm/pinpoint · error · NoSuchElementException
Invalid uri stat chart type:
Error message
Invalid uri stat chart type:
What it means
UriStatChartTypeFactory.valueOf looks up the type string in a prebuilt map of UriStatChartType instances and throws NoSuchElementException when the key is absent. It is a strict lookup: unlike enum valueOf it accepts custom type strings but must know them at registration time.
Solutions
- Use a chart type string supported by this build (check the keys registered in UriStatChartTypeFactory).
- Align frontend and backend versions so both know the same chart types.
- Handle NoSuchElementException in the controller and return a 404/400 listing valid types.
Example fix
// before
UriStatChartType t = factory.valueOf("bogusType");
// after
UriStatChartType t = factory.valueOf("cpu"); // a registered type key Defensive patterns
Strategy: try-catch
Validate before calling
UriStatChartType t = null; /* pre-check against the registered keys of uriStatCharts if exposed, else use try-catch */
Try / catch
try { t = factory.valueOf(type); } catch (NoSuchElementException e) { t = defaultChartType; } Prevention
- Keep client chart-type constants in sync with server registry
- Share the type list between modules
- Add tests covering all types sent by the frontend
When it happens
Trigger: Calling valueOf with a type string never registered in the factory's uriStatCharts map (or a typo / different case).
Common situations: Frontend sending a chart type parameter the backend version doesn't support; version mismatch between web UI and uristat-web module; renamed chart types.
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/06ee8c4363b47d0c.
Report an issue: GitHub.
Appendix: source
Thrown at uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/chart/UriStatChartTypeFactory.java:28
import java.util.stream.Collectors;
@Component
public class UriStatChartTypeFactory {
private final Map<String, UriStatChartType> uriStatCharts;
public UriStatChartTypeFactory(UriStatChartType... uriStatCharts) {
Objects.requireNonNull(uriStatCharts, "uriStatCharts");
this.uriStatCharts = Arrays.stream(uriStatCharts)
.collect(Collectors.toMap(UriStatChartType::getType, Function.identity()));
}
public UriStatChartType valueOf(String type) {
Objects.requireNonNull(type);
final UriStatChartType uriStatChartType = uriStatCharts.get(type);
if (uriStatChartType == null) {
throw new NoSuchElementException("Invalid uri stat chart type: " + type);
}
return uriStatChartType;
}
}
View on GitHub (pinned to 744c3d3075)