{"record":{"id":"26f7868196158159","repo":"appwrite/appwrite","slug":"attribute-value-invalid-26f786","errorCode":"ATTRIBUTE_VALUE_INVALID","errorMessage":"The attribute value is invalid. Please check the type, range and value of the attribute.","messagePattern":"The attribute value is invalid\\. Please check the type, range and value of the attribute\\.","errorType":"validation","errorClass":"Exception","httpStatus":400,"severity":"error","filePath":"src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Create.php","lineNumber":94,"sourceCode":"            ->inject('dbForProject')\n            ->inject('publisherForDatabase')\n            ->inject('queueForEvents')\n            ->inject('authorization')\n            ->callback($this->action(...));\n    }\n\n    public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?int $min, ?int $max, ?int $default, bool $array, UtopiaResponse $response, Database $dbForProject, DatabasePublisher $publisherForDatabase, Event $queueForEvents, Authorization $authorization): void\n    {\n        $min ??= \\PHP_INT_MIN;\n        $max ??= \\PHP_INT_MAX;\n\n        if ($min > $max) {\n            throw new Exception($this->getInvalidValueException(), 'Minimum value must be lesser than maximum value');\n        }\n\n        $validator = new Range($min, $max, Database::VAR_INTEGER);\n        if (!\\is_null($default) && !$validator->isValid($default)) {\n            throw new Exception($this->getInvalidValueException(), $validator->getDescription());\n        }\n\n        // The 4 byte column only holds a range that fits INT32. min counts: a\n        // column bounded below -2147483648 has to be able to store that value,\n        // and with min left out the bound is PHP_INT_MIN.\n        $size = $min >= -2147483648 && $max <= 2147483647 ? 4 : 8;\n\n        $attribute = $this->createAttribute($databaseId, $collectionId, new Document([\n            'key' => $key,\n            'type' => Database::VAR_INTEGER,\n            'size' => $size,\n            'required' => $required,\n            'default' => $default,\n            'array' => $array,\n            'format' => APP_DATABASE_ATTRIBUTE_INT_RANGE,\n            'formatOptions' => ['min' => $min, 'max' => $max],\n        ]), $response, $dbForProject, $publisherForDatabase, $queueForEvents, $authorization);\n","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/appwrite/appwrite/blob/ce3a85157f30ff289c7511f62ff076005fa106d1/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Create.php#L76-L112","documentation":"Thrown by Databases/Attributes Integer Create when the supplied default value fails the Range validator built from min/max (ATTRIBUTE_VALUE_INVALID). The message 'The attribute value is invalid...' carries the validator description; here specifically it fires when a non-null default falls outside the requested min..max interval for the integer attribute being created.","triggerScenarios":"POST /v1/databases/{databaseId}/collections/{collectionId}/attributes/integer (or the tablesDB equivalent createIntegerColumn) with a default outside [min,max] — e.g. min=0, max=100, default=-5 or default=1000; also default=0 with min=1; or a default set while min/max were chosen such that it is out of range.","commonSituations":"Copy-pasting default values from a differently-bounded column; forgetting that omitting min/max defaults the range to PHP_INT_MIN..PHP_INT_MAX but supplying a partial range (only min or only max) and a default that violates the other bound; frontend sending default as string-typed coercion issues are caught earlier, this one is purely a range violation.","solutions":["Adjust the default so it lies within [min,max], or widen min/max to include the desired default.","Omit the default entirely (leave it null) and set values per-document instead.","If you only need one bound, pass min or max and a default satisfying both implied bounds (unset bound becomes PHP_INT_MIN/PHP_INT_MAX).","Double-check the request body: default must be an integer, not a string, and within range."],"exampleFix":"// before\nPOST .../attributes/integer\n{ \"key\": \"age\", \"min\": 0, \"max\": 120, \"default\": 150 } // 150 > max -> ATTRIBUTE_VALUE_INVALID\n// after\n{ \"key\": \"age\", \"min\": 0, \"max\": 120, \"default\": 30 }","handlingStrategy":"validation","validationCode":"const valid = def === null || (min === null || def >= min) && (max === null || def <= max);\nif (!valid) throw new Error(`default ${def} outside [${min ?? '-inf'}, ${max ?? '+inf'}]`);","typeGuard":"function isDefaultInRange(def, min, max) {\n  return def === null || ((min === null || def >= min) && (max === null || def <= max));\n}","tryCatchPattern":"try {\n  await databases.createIntegerAttribute(dbId, colId, key, required, min, max, def);\n} catch (e) {\n  if (e.code === 'attribute_value_invalid') {\n    // retry with corrected default or without default\n  } else { throw e; }\n}","preventionTips":["Clamp the default to [min,max] in your form/API layer before calling the endpoint.","Remember unbounded sides imply PHP_INT_MIN/PHP_INT_MAX.","Never send a default when required=true.","Send default as a JSON number, not a string."],"tags":["validation","range","databases"],"backgroundTag":"invalid-argument-value","analyzedSha":"ce3a85157f30ff289c7511f62ff076005fa106d1","analyzedAt":"2026-09-08T08:30:15.067Z","contentChangedAt":"2026-09-08T08:30:15.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}