pinpoint-apm/pinpoint · error · InvalidParameterException
TimeWindow is required.
Error message
TimeWindow is required.
What it means
OtlpMetricChartQueryParameter uses a builder pattern, and build() enforces that a TimeWindow was set before constructing the immutable query parameter object. If timeWindow is null, an InvalidParameterException is thrown. The TimeWindow (range/r interval) is required for chart queries so the service can compute aggregation buckets.
Solutions
- Always call .timeWindow(new TimeWindow(from, to, interval)) on the builder before build().
- Derive the TimeWindow from the incoming request's from/to parameters and validate them at the controller layer.
- Add a unit test that exercises the full builder chain so a missing mandatory field fails in CI instead of at runtime.
Example fix
// before
OtlpMetricChartQueryParameter param = OtlpMetricChartQueryParameter.newChartQueryBuilder()
.setApplicationName(appName)
.build();
// after
OtlpMetricChartQueryParameter param = OtlpMetricChartQueryParameter.newChartQueryBuilder()
.setApplicationName(appName)
.setTimeWindow(new TimeWindow(from, to, interval))
.build(); Defensive patterns
Strategy: validation
Validate before calling
if (timeWindow == null) {
throw new IllegalArgumentException("request must include from/to/interval to build a TimeWindow");
} Type guard
boolean isChartParameterComplete(OtlpMetricChartQueryParameter.ChartQueryBuilder b) {
return b.getTimeWindow() != null; // check before build()
} Try / catch
try {
OtlpMetricChartQueryParameter p = builder.build();
} catch (InvalidParameterException e) {
return ResponseEntity.badRequest().body("time range (from/to/interval) is required");
} Prevention
- Set timeWindow immediately after creating the builder, before other optional fields
- Validate request time-range parameters at the controller layer
- Add builder tests covering the full mandatory chain
When it happens
Trigger: Calling OtlpMetricChartQueryParameter.ChartQueryBuilder.build() without having called timeWindow(...) on the builder first.
Common situations: New code paths constructing chart query parameters forget the timeWindow step; refactors that changed the builder chain; unit tests exercising build() with partial parameters; conditional logic that skips setting timeWindow when a request lacks a time range.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- TimeWindow is required.
- annotationKey name must not be empty
- Either tagGroupList or fieldNameList must have a size of…
- eventIdentifier cannot be less than 0
- invalid operator - not found left operand. operator=
AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07).
Data as JSON: /api/errors/357c927fe652000d.
Report an issue: GitHub.
Appendix: source
Thrown at otlpmetric/otlpmetric-web/src/main/java/com/navercorp/pinpoint/otlp/web/vo/OtlpMetricChartQueryParameter.java:127
public Builder setLimit(int limit) {
this.limit = Ints.constrainToRange(limit, 50, 200);
return self();
}
public Builder setTimeWindow(TimeWindow timeWindow) {
this.timeWindow = timeWindow;
this.range = timeWindow.getWindowRange();
this.timeSize = timeWindow.getWindowSlotSize();
this.timePrecision = TimePrecision.newTimePrecision(TimeUnit.MILLISECONDS, timeWindow.getWindowSlotSize());
this.limit = timeWindow.getWindowRangeCount();
return self();
}
@Override
public OtlpMetricChartQueryParameter build() {
if (timeWindow == null) {
throw new InvalidParameterException("TimeWindow is required.");
}
return new OtlpMetricChartQueryParameter(this);
}
}
@Override
public String toString() {
return "OtlpMetricChartQueryParameter{" +
"serviceName='" + serviceName + '\'' +
", applicationName='" + applicationName + '\'' +
", agentId='" + agentId + '\'' +
", metricGroupName='" + metricGroupName + '\'' +
", metricName='" + metricName + '\'' +
", fieldName='" + fieldName + '\'' +
", tags=" + tags +
", version='" + version + '\'' +
", aggregationFunction=" + aggregationFunction +View on GitHub (pinned to 744c3d3075)