Skip to content

Conversation

@yesrod
Copy link

@yesrod yesrod commented Jan 22, 2026

The rest of the code is already set up to treat 0 as "unlimited", as far as I can tell, but the UI elements were limiting the minimum to 1. This change allows users to specify unlimited resources for a specific server if the user is not globally limited in that resource. I've tested this on my local Pelican instance, and it works as intended.

Summary by CodeRabbit

  • Bug Fixes
    • Updated server resource input validation to allow zero values for CPU, memory, and disk fields, removing the previous minimum requirement of 1.

✏️ Tip: You can customize this high-level summary in your review settings.

The rest of the code is already set up to treat 0 as "unlimited", as far as I can tell, but the UI elements were limiting the minimum to 1.

This change allows users to specify unlimited resources for a specific server if the user is unlimited in that resource.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

This pull request modifies validation rules for server resource fields (CPU, memory, and disk) across two Filament component files, changing the minimum allowed value from 1 to 0, thereby permitting zero resource allocation entries.

Changes

Cohort / File(s) Summary
Resource Field Validation Updates
user-creatable-servers/src/Filament/Components/Actions/CreateServerAction.php, user-creatable-servers/src/Filament/Server/Pages/ServerResourcePage.php
Changed minValue from 1 to 0 for CPU, memory, and disk input fields, allowing zero as valid input values while preserving all other validation rules and helper text.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A rabbit hops with glee today,
Zero barriers now hold no sway,
Resources dance where once they'd balk,
The servers now walk, hop, and walk! 🐰✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main change: dropping the minimum limit for user-created server resources from 1 to 0, which aligns with the modifications in both affected files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0005ab0 and 1f9ce60.

📒 Files selected for processing (2)
  • user-creatable-servers/src/Filament/Components/Actions/CreateServerAction.php
  • user-creatable-servers/src/Filament/Server/Pages/ServerResourcePage.php
🧰 Additional context used
🧬 Code graph analysis (1)
user-creatable-servers/src/Filament/Components/Actions/CreateServerAction.php (1)
user-creatable-servers/src/Models/UserResourceLimits.php (2)
  • getCpuLeft (40-49)
  • getMemoryLeft (51-60)

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
user-creatable-servers/src/Filament/Server/Pages/ServerResourcePage.php (1)

65-93: Apply the same conditional minimum here to avoid “unlimited” bypass.

The edit form now permits 0 regardless of whether the user has finite limits. If 0 means “unlimited,” this can exceed quotas. Consider mirroring the conditional minimums here as well.

✅ Suggested adjustment
                 TextInput::make('cpu')
                     ->label(trans('user-creatable-servers::strings.cpu'))
                     ->required()
                     ->live(onBlur: true)
                     ->hint(fn ($state) => $userResourceLimits->cpu > 0 ? ($maxCpu - $state . '% ' . trans('user-creatable-servers::strings.left')) : trans('user-creatable-servers::strings.unlimited'))
                     ->hintColor(fn ($state) => $userResourceLimits->cpu > 0 && $maxCpu - $state < 0 ? 'danger' : null)
                     ->numeric()
-                    ->minValue(0)
+                    ->minValue($userResourceLimits->cpu > 0 ? 1 : 0)
                     ->maxValue($userResourceLimits->cpu > 0 ? $maxCpu : null)
                     ->suffix('%'),
                 TextInput::make('memory')
                     ->label(trans('user-creatable-servers::strings.memory'))
                     ->required()
                     ->live(onBlur: true)
                     ->hint(fn ($state) => $userResourceLimits->memory > 0 ? ($maxMemory - $state . $suffix . ' ' . trans('user-creatable-servers::strings.left')) : trans('user-creatable-servers::strings.unlimited'))
                     ->hintColor(fn ($state) => $userResourceLimits->memory > 0 && $maxMemory - $state < 0 ? 'danger' : null)
                     ->numeric()
-                    ->minValue(0)
+                    ->minValue($userResourceLimits->memory > 0 ? 1 : 0)
                     ->maxValue($userResourceLimits->memory > 0 ? $maxMemory : null)
                     ->suffix($suffix),
                 TextInput::make('disk')
                     ->label(trans('user-creatable-servers::strings.disk'))
                     ->required()
                     ->live(onBlur: true)
                     ->hint(fn ($state) => $userResourceLimits->disk > 0 ? ($maxDisk - $state . $suffix . ' ' . trans('user-creatable-servers::strings.left')) : trans('user-creatable-servers::strings.unlimited'))
                     ->hintColor(fn ($state) => $userResourceLimits->disk > 0 && $maxDisk - $state < 0 ? 'danger' : null)
                     ->numeric()
-                    ->minValue(0)
+                    ->minValue($userResourceLimits->disk > 0 ? 1 : 0)
                     ->maxValue($userResourceLimits->disk > 0 ? $maxDisk : null)
                     ->suffix($suffix),
user-creatable-servers/src/Filament/Components/Actions/CreateServerAction.php (1)

58-77: Align minValue with backend validation for finite user quotas.

When a user has a finite resource limit, the backend canCreateServer() enforces per-server values > 0 by rejecting <= 0. However, the UI currently allows minValue(0) unconditionally, creating a mismatch: users can submit 0, which the backend will reject. Make minValue conditional to match backend behavior.

✅ Suggested adjustment
                TextInput::make('cpu')
                     ->label(trans('user-creatable-servers::strings.cpu'))
                     ->required()
                     ->numeric()
-                    ->minValue(0)
+                    ->minValue($userResourceLimits->cpu > 0 ? 1 : 0)
                     ->maxValue($userResourceLimits->getCpuLeft())
                     ->suffix('%'),
                 TextInput::make('memory')
                     ->label(trans('user-creatable-servers::strings.memory'))
                     ->required()
                     ->numeric()
-                    ->minValue(0)
+                    ->minValue($userResourceLimits->memory > 0 ? 1 : 0)
                     ->maxValue($userResourceLimits->getMemoryLeft())
                     ->suffix(config('panel.use_binary_prefix') ? 'MiB' : 'MB'),
                 TextInput::make('disk')
                     ->label(trans('user-creatable-servers::strings.disk'))
                     ->required()
                     ->numeric()
-                    ->minValue(0)
+                    ->minValue($userResourceLimits->disk > 0 ? 1 : 0)
                     ->maxValue($userResourceLimits->getDiskLeft())
                     ->suffix(config('panel.use_binary_prefix') ? 'MiB' : 'MB'),
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0005ab0 and 1f9ce60.

📒 Files selected for processing (2)
  • user-creatable-servers/src/Filament/Components/Actions/CreateServerAction.php
  • user-creatable-servers/src/Filament/Server/Pages/ServerResourcePage.php
🧰 Additional context used
🧬 Code graph analysis (1)
user-creatable-servers/src/Filament/Components/Actions/CreateServerAction.php (1)
user-creatable-servers/src/Models/UserResourceLimits.php (2)
  • getCpuLeft (40-49)
  • getMemoryLeft (51-60)

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant