{"record":{"id":"7e9086b1082c3f74","repo":"openzipkin/zipkin","slug":"minduration-0","errorCode":null,"errorMessage":"minDuration <= 0","messagePattern":"minDuration <= 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"zipkin/src/main/java/zipkin2/storage/QueryRequest.java","lineNumber":254,"sourceCode":"      this.limit = limit;\n      return this;\n    }\n\n    public QueryRequest build() {\n      // coerce service and span names to lowercase\n      if (serviceName != null) serviceName = serviceName.toLowerCase(Locale.ROOT);\n      if (remoteServiceName != null) remoteServiceName = remoteServiceName.toLowerCase(Locale.ROOT);\n      if (spanName != null) spanName = spanName.toLowerCase(Locale.ROOT);\n\n      if (\"\".equals(serviceName)) serviceName = null;\n      if (\"\".equals(remoteServiceName)) remoteServiceName = null;\n      if (\"\".equals(spanName) || \"all\".equals(spanName)) spanName = null;\n\n      if (endTs <= 0) throw new IllegalArgumentException(\"endTs <= 0\");\n      if (limit <= 0) throw new IllegalArgumentException(\"limit <= 0\");\n      if (lookback <= 0) throw new IllegalArgumentException(\"lookback <= 0\");\n      if (minDuration != null) {\n        if (minDuration <= 0) throw new IllegalArgumentException(\"minDuration <= 0\");\n        if (maxDuration != null && maxDuration < minDuration) {\n          throw new IllegalArgumentException(\"maxDuration < minDuration\");\n        }\n      } else if (maxDuration != null) {\n        throw new IllegalArgumentException(\"maxDuration is only valid with minDuration\");\n      }\n\n      return new QueryRequest(\n        serviceName,\n        remoteServiceName,\n        spanName,\n        annotationQuery,\n        minDuration,\n        maxDuration,\n        endTs,\n        lookback,\n        limit\n      );","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin/src/main/java/zipkin2/storage/QueryRequest.java#L236-L272","documentation":"Thrown by QueryRequest.Builder.build() when minDuration is set to zero or a negative value. minDuration filters traces by span duration in microseconds, and a non-positive duration is meaningless as a filter. Zipkin rejects it at build time rather than returning wrong results.","triggerScenarios":"Calling .minDuration(0L) or .minDuration(-5L) on the builder; converting a user-supplied duration in the wrong unit (e.g. passing 0 nanoseconds after integer division, or a value already divided to 0); passing a duration string that failed to parse and defaulted to 0.","commonSituations":"Unit confusion between milliseconds, microseconds, and nanoseconds leading to a computed 0; a 'min duration' UI field left blank and coerced to 0; copying example code that used 0 as a placeholder.","solutions":["Pass a positive duration in microseconds, e.g. .minDuration(100000) for 100ms","If minDuration is optional, leave it unset (null) instead of setting it to 0","Audit unit conversions feeding the value (ms to micros is *1000, nanos to micros is /1000)"],"exampleFix":"// before\nbuilder.minDuration(durationMs / 1000); // integer division may yield 0\n\n// after\nbuilder.minDuration(durationMs * 1000); // milliseconds -> microseconds","handlingStrategy":"validation","validationCode":"// duration is in microseconds; must be positive if present\nif (minDuration != null && minDuration <= 0) {\n    throw new IllegalArgumentException(\"minDuration must be positive microseconds, got: \" + minDuration);\n}\nQueryRequest.Builder b = QueryRequest.newBuilder().endTs(endTs).limit(10);\nif (minDuration != null) b.minDuration(minDuration);","typeGuard":null,"tryCatchPattern":"try {\n    builder.minDuration(minDurationMicros);\n} catch (IllegalArgumentException e) {\n    // input bug, never retry: surface the message to the caller/API client\n    throw new BadRequestException(e.getMessage(), e);\n}","preventionTips":["Name variables with their unit (minDurationMicros) to prevent ms/micros mix-ups","Treat a blank/absent duration filter as null, not 0","Write one conversion helper for ms->micros and use it everywhere"],"tags":["java","zipkin","validation","duration","units"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}