{"record":{"id":"34c8b29ae12f3b7e","repo":"alibaba/nacos","slug":"malformed-factor","errorCode":null,"errorMessage":"malformed factor","messagePattern":"malformed factor","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java","lineNumber":398,"sourceCode":"    /**\n     * Validate health params.\n     *\n     * @param healthParams health params\n     */\n    public void validateHealthParams(SwitchDomain.HealthParams healthParams) {\n        if (healthParams.getMin() < SwitchDomain.HttpHealthParams.MIN_MIN) {\n            throw new IllegalArgumentException(\"min check time for http or tcp is too small(<500)\");\n        }\n        \n        if (healthParams.getMax() < SwitchDomain.HttpHealthParams.MIN_MAX) {\n            \n            throw new IllegalArgumentException(\n                \"max check time for http or tcp is too small(<3000)\");\n        }\n        \n        if (healthParams.getFactor() < 0 || healthParams.getFactor() > 1) {\n            \n            throw new IllegalArgumentException(\"malformed factor\");\n        }\n    }\n    \n    private void updateWithConsistency(SwitchDomain tempSwitchDomain) throws NacosException {\n        try {\n            final BatchWriteRequest req = new BatchWriteRequest();\n            String switchDomainKey = KeyBuilder.getSwitchDomainKey();\n            Datum datum = Datum.createDatum(switchDomainKey, tempSwitchDomain);\n            req.append(ByteUtils.toBytes(switchDomainKey), serializer.serialize(datum));\n            WriteRequest operationLog = WriteRequest.newBuilder().setGroup(group())\n                .setOperation(OldDataOperation.Write.getDesc())\n                .setData(ByteString.copyFrom(serializer.serialize(req)))\n                .build();\n            protocolManager.getCpProtocol().write(operationLog);\n        } catch (Exception e) {\n            Loggers.RAFT.error(\"Submit switch domain failed: \", e);\n            throw new NacosException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage());\n        }","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java#L380-L416","documentation":"Thrown by validateHealthParams when healthParams.getFactor() is outside the range [0, 1]. The factor is the re-evaluation factor for response-time-based health-check interval adjustment. It must be a float between 0.0 and 1.0 inclusive.","triggerScenarios":"PUT /v3/admin/ns/operator/switches with entry=httpHealthParams or tcpHealthParams and a valid JSON whose 'factor' field is < 0 or > 1, e.g. {\"min\":500,\"max\":5000,\"factor\":1.5} or {\"min\":500,\"max\":5000,\"factor\":-0.1}.","commonSituations":"Passing factor as a percentage (e.g. 85 instead of 0.85), or typo in decimal placement.","solutions":["Set 'factor' to a float in [0.0, 1.0], e.g. 0.85.","If you think in percentages, divide by 100 before sending."],"exampleFix":"// before\nPUT /v3/admin/ns/operator/switches?entry=httpHealthParams&value={\"min\":500,\"max\":5000,\"factor\":85}\n// after\nPUT /v3/admin/ns/operator/switches?entry=httpHealthParams&value={\"min\":500,\"max\":5000,\"factor\":0.85}","handlingStrategy":"validation","validationCode":"float factor = healthParams.getFactor();\nif (factor < 0 || factor > 1) {\n    throw new IllegalArgumentException(\"Health check factor must be in [0.0, 1.0]\");\n}","typeGuard":"function isValidFactor(factor: number): boolean {\n  return factor >= 0 && factor <= 1;\n}","tryCatchPattern":"try {\n  operatorV2Impl.updateSwitch(entry, json, debug);\n} catch (NacosApiException e) {\n  if (e.getMessage().includes(\"malformed factor\")) {\n    params.factor = 0.85;\n    json = JSON.stringify(params);\n  }\n}","preventionTips":["Factor is a ratio in [0.0, 1.0], not a percentage.","If using percentages, divide by 100."],"tags":["naming","switch","validation","health-params"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}