{"record":{"id":"7292d84e5627d3f3","repo":"material-components/material-components-android","slug":"minseparation-s-must-be-greater-or-equal-to-0","errorCode":null,"errorMessage":"minSeparation(%s) must be greater or equal to 0","messagePattern":"minSeparation\\((.+?)\\) must be greater or equal to 0","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/slider/BaseSlider.java","lineNumber":758,"sourceCode":"          String.format(EXCEPTION_ILLEGAL_VALUE_FROM, valueFrom, valueTo));\n    }\n\n    for (Float value : values) {\n      if (value < valueFrom || value > valueTo) {\n        throw new IllegalStateException(\n            String.format(EXCEPTION_ILLEGAL_VALUE, value, valueFrom, valueTo));\n      }\n      if (stepSize > 0.0f && !valueLandsOnTick(value)) {\n        throw new IllegalStateException(\n            String.format(EXCEPTION_ILLEGAL_DISCRETE_VALUE, value, valueFrom, stepSize, stepSize));\n      }\n    }\n  }\n\n  private void validateMinSeparation() {\n    final float minSeparation = getMinSeparation();\n    if (minSeparation < 0) {\n      throw new IllegalStateException(\n          String.format(EXCEPTION_ILLEGAL_MIN_SEPARATION, minSeparation));\n    }\n    if (stepSize > 0 && minSeparation > 0) {\n      if (separationUnit != UNIT_VALUE) {\n        throw new IllegalStateException(\n            String.format(\n                EXCEPTION_ILLEGAL_MIN_SEPARATION_STEP_SIZE_UNIT, minSeparation, stepSize));\n      }\n      if (minSeparation < stepSize || !isMultipleOfStepSize(minSeparation)) {\n        throw new IllegalStateException(\n            String.format(\n                EXCEPTION_ILLEGAL_MIN_SEPARATION_STEP_SIZE, minSeparation, stepSize, stepSize));\n      }\n    }\n  }\n\n  private void warnAboutFloatingPointError() {\n    if (stepSize == 0) {","sourceCodeStart":740,"sourceCodeEnd":776,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/slider/BaseSlider.java#L740-L776","documentation":"Thrown by validateMinSeparation() when the minimum separation between neighboring thumbs (set via setMinSeparation) is negative. Min separation is only meaningful as zero or positive; a negative value indicates a caller error or a bad dimension resource.","triggerScenarios":"Calling setMinSeparation(-n) or setMinSeparationDimension with a negative dimension; XML app:minSeparation set to a negative value; computing separation from user input without validation.","commonSituations":"Deriving minSeparation from a formula (e.g. step or range percentage) that can go negative on edge-case inputs; passing a negative pixel dimension from a design token or dimen resource.","solutions":["Pass 0 or a positive value to setMinSeparation.","Math.max(0, computedSeparation) before calling the setter.","Check the app:minSeparation attribute in the layout XML for negative values.","Recompute separation relative to (valueTo - valueFrom) if it depends on the range."],"exampleFix":"// before\nslider.setMinSeparation(-2f);\n\n// after\nslider.setMinSeparation(Math.max(0f, computedSeparation));","handlingStrategy":"validation","validationCode":"float safeSep = Math.max(0f, computedSeparation);\nslider.setMinSeparation(safeSep);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat 0 as the 'no separation' sentinel, never a negative number.","Audit XML app:minSeparation values in code review."],"tags":["android","slider","material-components","configuration","range-slider"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}