You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
🐛: Attribute size field in console allows the character "e" to be typed when it should only allows whole numbers #9217
Go to Attributes, and click "Create attribute". Pick any value option except boolean.
In the size field, it seems to not allow any alphabet character and should only be expecting whole numbers
However, in the size field, I'm able to type the letter "e". When I submit, I get an inaccurate error message for the problem.
👍 Expected behavior
I shouldn't be able to type the letter e. And tbh, I shouldn't be able to type a period either for decimals since it expects whole numbers, but the error message is nicely stated there.
👎 Actual Behavior
🎲 Appwrite version
Appwrite Cloud
💻 Operating system
MacOS
🧱 Your Environment
Console
👀 Have you spent some time to check if this issue has been raised before?
changed the title [-]🐛: Attribute size field in console allows the character "e" and "." to be typed when it only expects whole numbers[/-][+]🐛: Attribute size field in console allows the character "e" to be typed when it only expects whole numbers[/+]on Jan 13, 2025
changed the title [-]🐛: Attribute size field in console allows the character "e" to be typed when it only expects whole numbers[/-][+]🐛: Attribute size field in console allows the character "e" to be typed when it should only allows whole numbers[/+]on Jan 13, 2025
Hey @viknith, I tried using different characters and found that . and -- are also allowed in the numbers field. I’d like to contribute to this issue. And I got know that the error is in-Built php value where
->param('size', null, new Range(1, APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH, Range::TYPE_INTEGER), 'Attribute size for text attributes, in number of characters.')
Where the error is TYPE_INTEGER it allows the "e" values because of exponential notation and also "." is also allowed due to decimal values and -- is allowed because of decrement values.
I don't think there's any assigning process, just go ahead and work on it if you'd like :), I'm just a dude passing by that noticed this while playing around with AppWrite.
@Bayyana-kiran Good catch on identifying the root cause! Here's the best way to fix this:
The Problem
You're correct - Range::TYPE_INTEGER uses PHP's is_numeric() which accepts:
Exponential notation ("1e5")
Decimals ("3.14")
Negative signs ("--5")
The Solution
Don't use regex for this. Instead, create a proper integer validator. Here's the approach:
Option 1: Update the Range Validator (Cleanest)
In /src/Utopia/Validator/Range.php, modify the validation:
protectedfunctionisValid($value): bool
{
if ($this->type === self::TYPE_INTEGER) {
// Use ctype_digit for strict integer validation (no e, ., -)if (!ctype_digit((string)$value)) {
returnfalse;
}
$value = (int)$value;
}
// ... rest of range checking
}
Option 2: Add Client-Side Validation (Quick Win)
In the Console form component, add HTML5 validation:
The oninput handler immediately strips non-digits, preventing "e", ".", and "--" from being typed.
Option 3: Both (Best Approach)
Do both - fix the server-side validator AND add client-side prevention for better UX.
Why Not Regex?
Regex works, but it's overkill here. ctype_digit() is:
Faster
More readable
Built for this exact use case
Already used elsewhere in Appwrite codebase
Testing
Make sure to test:
// Should PASS$validator->isValid("100");
$validator->isValid("1");
// Should FAIL$validator->isValid("1e5"); // exponential$validator->isValid("3.14"); // decimal$validator->isValid("--5"); // double negative$validator->isValid("-5"); // negative (if min is 1)
Let me know if you need help with the PR! I've worked on similar input validation issues before and can review.
Hi @Meldiron! I've reproduced #9217 in the current Appwrite Console and traced the underlying input-handling issue.
Under TablesDB → Columns → Create Column → Varchar, I observed:
Typing e leaves it visible even after losing focus.
Pasting 1e3 silently converts the Size value to 1.
Pasting 2.5 silently converts it to 2.
The cause of the silent conversion is in apps/console/src/components/pages/projects/$projectId/databases/tablesdb/Column.tsx. Both Varchar and deprecated String use parseInt() without validating the complete input, allowing invalid numeric representations to be truncated.
Proposed fix: Preserve the raw Size input, validate it as a whole number, and convert it only after validation. I'll also add regression coverage for invalid input, valid boundaries, and both affected column types.
One implementation detail I'd like your input on: should invalid characters be rejected immediately, or preserved with an inline validation error?
I'd like to take ownership of this fix. Could you confirm the preferred behavior and assign #9217 to me so I can proceed?
Activity
[-]🐛: Attribute size field in console allows the character "e" and "." to be typed when it only expects whole numbers[/-][+]🐛: Attribute size field in console allows the character "e" to be typed when it only expects whole numbers[/+][-]🐛: Attribute size field in console allows the character "e" to be typed when it only expects whole numbers[/-][+]🐛: Attribute size field in console allows the character "e" to be typed when it should only allows whole numbers[/+]arilui commentedon Jan 27, 2025
I'm working on this
IgorJanGit commentedon Jan 30, 2025
I am working on this
Bayyana-kiran commentedon Feb 5, 2025
Hey @viknith, I tried using different characters and found that . and -- are also allowed in the numbers field. I’d like to contribute to this issue. And I got know that the error is in-Built php value where
->param('size', null, new Range(1, APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH, Range::TYPE_INTEGER), 'Attribute size for text attributes, in number of characters.')Where the error is TYPE_INTEGER it allows the "e" values because of exponential notation and also "." is also allowed due to decimal values and -- is allowed because of decrement values.
Could you please assign it to me?
viknith commentedon Feb 6, 2025
I don't think there's any assigning process, just go ahead and work on it if you'd like :), I'm just a dude passing by that noticed this while playing around with AppWrite.
Bayyana-kiran commentedon Feb 7, 2025
@viknith I'm working on it and I will try to merge it 😄
Bayyana-kiran commentedon Feb 20, 2025
@viknith Hey I got an doubt The input field need to allow only whole numbers only because I'm trying to code up a regex for that.
D0CT4 commentedon Oct 21, 2025
@Bayyana-kiran Good catch on identifying the root cause! Here's the best way to fix this:
The Problem
You're correct -
Range::TYPE_INTEGERuses PHP'sis_numeric()which accepts:The Solution
Don't use regex for this. Instead, create a proper integer validator. Here's the approach:
Option 1: Update the Range Validator (Cleanest)
In
/src/Utopia/Validator/Range.php, modify the validation:Option 2: Add Client-Side Validation (Quick Win)
In the Console form component, add HTML5 validation:
The
oninputhandler immediately strips non-digits, preventing "e", ".", and "--" from being typed.Option 3: Both (Best Approach)
Do both - fix the server-side validator AND add client-side prevention for better UX.
Why Not Regex?
Regex works, but it's overkill here.
ctype_digit()is:Testing
Make sure to test:
Let me know if you need help with the PR! I've worked on similar input validation issues before and can review.
Bayyana-kiran commentedon Oct 22, 2025
Ok @D0CT4 I will try to work on it.
saaahilhussain commentedon Oct 20, 2026
Hi @Meldiron! I've reproduced #9217 in the current Appwrite Console and traced the underlying input-handling issue.
Under TablesDB → Columns → Create Column → Varchar, I observed:
eleaves it visible even after losing focus.1e3silently converts the Size value to1.2.5silently converts it to2.The cause of the silent conversion is in
apps/console/src/components/pages/projects/$projectId/databases/tablesdb/Column.tsx. Both Varchar and deprecated String useparseInt()without validating the complete input, allowing invalid numeric representations to be truncated.Proposed fix: Preserve the raw Size input, validate it as a whole number, and convert it only after validation. I'll also add regression coverage for invalid input, valid boundaries, and both affected column types.
One implementation detail I'd like your input on: should invalid characters be rejected immediately, or preserved with an inline validation error?
I'd like to take ownership of this fix. Could you confirm the preferred behavior and assign #9217 to me so I can proceed?