openmediavault/openmediavault · error · SchemaValidationException

: The value is not a number.

Error message

%s: The value %s is not a number.

What it means

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.

Solutions

  1. Cast the value to the right type before validation: is_numeric($v) ? $v + 0 : $v (int or float).
  2. Fix the caller (form/RPC client) to emit real JSON numbers instead of quoted strings.
  3. If the field may legitimately be a string or number, change the schema to "type": ["number", "string"] or add a custom coercion.
  4. Inspect the $name prefix in the message to locate the exact property in the schema and the offending payload with json_encode_safe.

Example fix

// before
$data = ['shares' => [['size' => $_POST['size']]]]; // '1024' (string)
$object->validate($data, $schema);
// after
$data = ['shares' => [['size' => is_numeric($_POST['size']) ? $_POST['size'] + 0 : 0]]];
$object->validate($data, $schema);
Defensive patterns

Strategy: validation

Validate before calling

// PHP: ensure numeric before calling Schema->validate()
function assertNumber($v): void {
    if (!is_numeric($v)) {
        throw new InvalidArgumentException('Expected number, got: ' . json_encode_safe($v));
    }
}

Type guard

function isNumber($v): bool { return is_int($v) || is_float($v) || is_numeric($v); }

Try / catch

try {
    $object->validate($data, $schema);
} catch (OMV\Json\SchemaValidationException $e) {
    $logger->error('Schema validation failed: ' . $e->getMessage());
    // reject request / return 400
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of openmediavault/openmediavault@dce610eb66 (2026-09-15). Data as JSON: /api/errors/fbe11bb2a6ba5f7a. Report an issue: GitHub.

Appendix: source

Thrown at deb/openmediavault/usr/share/php/openmediavault/json/schema.inc:401

            throw new SchemaValidationException(
                "%s: The value %s is not an integer.",
                $name,
                json_encode_safe($value)
            );
        }
        $this->checkMinimum($value, $schema, $name);
        $this->checkExclusiveMinimum($value, $schema, $name);
        $this->checkMaximum($value, $schema, $name);
        $this->checkExclusiveMaximum($value, $schema, $name);
        $this->checkEnum($value, $schema, $name);
        $this->checkOneOf($value, $schema, $name);
        $this->checkNot($value, $schema, $name);
    }

    protected function validateNumber($value, $schema, $name)
    {
        if (!is_numeric($value)) {
            throw new SchemaValidationException(
                "%s: The value %s is not a number.",
                $name,
                json_encode_safe($value)
            );
        }
        $this->checkMinimum($value, $schema, $name);
        $this->checkExclusiveMinimum($value, $schema, $name);
        $this->checkMaximum($value, $schema, $name);
        $this->checkExclusiveMaximum($value, $schema, $name);
        $this->checkEnum($value, $schema, $name);
        $this->checkOneOf($value, $schema, $name);
        $this->checkNot($value, $schema, $name);
    }

    protected function validateString($value, $schema, $name)
    {
        if (!is_string($value)) {
            throw new SchemaValidationException(

View on GitHub (pinned to dce610eb66)