{"record":{"id":"fbe11bb2a6ba5f7a","repo":"openmediavault/openmediavault","slug":"s-the-value-s-is-not-a-number","errorCode":null,"errorMessage":"%s: The value %s is not a number.","messagePattern":"(.+?): The value (.+?) is not a number\\.","errorType":"validation","errorClass":"SchemaValidationException","httpStatus":null,"severity":"error","filePath":"deb/openmediavault/usr/share/php/openmediavault/json/schema.inc","lineNumber":401,"sourceCode":"            throw new SchemaValidationException(\n                \"%s: The value %s is not an integer.\",\n                $name,\n                json_encode_safe($value)\n            );\n        }\n        $this->checkMinimum($value, $schema, $name);\n        $this->checkExclusiveMinimum($value, $schema, $name);\n        $this->checkMaximum($value, $schema, $name);\n        $this->checkExclusiveMaximum($value, $schema, $name);\n        $this->checkEnum($value, $schema, $name);\n        $this->checkOneOf($value, $schema, $name);\n        $this->checkNot($value, $schema, $name);\n    }\n\n    protected function validateNumber($value, $schema, $name)\n    {\n        if (!is_numeric($value)) {\n            throw new SchemaValidationException(\n                \"%s: The value %s is not a number.\",\n                $name,\n                json_encode_safe($value)\n            );\n        }\n        $this->checkMinimum($value, $schema, $name);\n        $this->checkExclusiveMinimum($value, $schema, $name);\n        $this->checkMaximum($value, $schema, $name);\n        $this->checkExclusiveMaximum($value, $schema, $name);\n        $this->checkEnum($value, $schema, $name);\n        $this->checkOneOf($value, $schema, $name);\n        $this->checkNot($value, $schema, $name);\n    }\n\n    protected function validateString($value, $schema, $name)\n    {\n        if (!is_string($value)) {\n            throw new SchemaValidationException(","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/openmediavault/openmediavault/blob/dce610eb66f624c640d0eb7ce401ddd65b763520/deb/openmediavault/usr/share/php/openmediavault/json/schema.inc#L383-L419","documentation":"This is thrown by openmediavault's JSON schema validator (openmediavault\\json\\Schema::validateNumber) when a value bound to a schema node of type \"number\" fails is_numeric(). The library enforces JSON-Schema-style type constraints before applying numeric constraints like minimum/maximum. The exception message interpolates the schema property path ($name) and a JSON-encoded dump of the offending value.","triggerScenarios":"Calling Schema->validate($data, $schema) (directly or via rpc/config request validation) where a schema property declares \"type\": \"number\" but the supplied data is a string, bool, null, array or object, e.g. {\"port\": \"8080\"} instead of {\"port\": 8080}. Also occurs when numeric values are submitted as strings from HTML forms or CLI arguments without casting.","commonSituations":"Frontend form fields submitting numeric config values as strings; RPC clients sending quoted numbers in JSON; PHP code reading values from text config files or $_GET/$_POST (always strings) and passing them into the config schema; decoders that preserve \"8080\" as a string.","solutions":["Cast the value to the right type before validation: is_numeric($v) ? $v + 0 : $v (int or float).","Fix the caller (form/RPC client) to emit real JSON numbers instead of quoted strings.","If the field may legitimately be a string or number, change the schema to \"type\": [\"number\", \"string\"] or add a custom coercion.","Inspect the $name prefix in the message to locate the exact property in the schema and the offending payload with json_encode_safe."],"exampleFix":"// before\n$data = ['shares' => [['size' => $_POST['size']]]]; // '1024' (string)\n$object->validate($data, $schema);\n// after\n$data = ['shares' => [['size' => is_numeric($_POST['size']) ? $_POST['size'] + 0 : 0]]];\n$object->validate($data, $schema);","handlingStrategy":"validation","validationCode":"// PHP: ensure numeric before calling Schema->validate()\nfunction assertNumber($v): void {\n    if (!is_numeric($v)) {\n        throw new InvalidArgumentException('Expected number, got: ' . json_encode_safe($v));\n    }\n}","typeGuard":"function isNumber($v): bool { return is_int($v) || is_float($v) || is_numeric($v); }","tryCatchPattern":"try {\n    $object->validate($data, $schema);\n} catch (OMV\\Json\\SchemaValidationException $e) {\n    $logger->error('Schema validation failed: ' . $e->getMessage());\n    // reject request / return 400\n}","preventionTips":["Cast form/CLI inputs with +0 or (float) before building the config payload.","Never quote numbers in JSON payloads emitted by clients.","Validate one schema node in a unit test with both valid and invalid types.","Prefer strict comparisons and gettype() checks when normalizing external input."],"tags":["php","json-schema","validation","type-error"],"backgroundTag":"schema-validation-failed","analyzedSha":"dce610eb66f624c640d0eb7ce401ddd65b763520","analyzedAt":"2026-09-15T09:48:09.960Z","contentChangedAt":"2026-09-15T09:48:09.960Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}