Skip to content

Conversation

@Boy132
Copy link
Member

@Boy132 Boy132 commented Aug 15, 2025

Closes #1617

@Boy132 Boy132 self-assigned this Aug 15, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 15, 2025

📝 Walkthrough

Walkthrough

Translations for schedule import UI were moved from admin/schedule.* to server/schedule.import_action.*, with some labels hidden. A new 'invalid' translation and import_action group were added. ScheduleResource now wraps cron next-run computation in try/catch to avoid exceptions during rendering.

Changes

Cohort / File(s) Summary
Import action translation refactor
app/Filament/Components/Actions/ImportScheduleAction.php
Switched translation keys from admin/schedule.* to server/schedule.import_action.*; applied hiddenLabel() to relevant fields; updated validation attributes and notification titles accordingly.
Cron next-run error handling
app/Filament/Server/Resources/ScheduleResource.php
Wrapped next run time computation in try/catch within the Cron section description; falls back to translated “invalid” on exception.
Language keys migration
lang/en/admin/schedule.php, lang/en/server/schedule.php
Removed admin schedule translations; added server schedule keys: top-level 'invalid' and 'import_action' group with file/url/help/add_url/import_failed/import_success.

Assessment against linked issues

Objective Addressed Explanation
Prevent 500 error when cron is invalid; provide clear error on save (#1617) Rendering is guarded with try/catch, but no explicit validation or save-time error messaging is added. Root cause of 500 during save vs. render is unclear.

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Migrate import UI translations from admin/schedule.* to server/schedule.import_action.* and hide labels (app/Filament/Components/Actions/ImportScheduleAction.php, multiple lines) Unrelated to fixing cron-related 500 errors or adding validation for cron fields.
Delete admin schedule language file (lang/en/admin/schedule.php, entire file) Language file removal is not tied to resolving cron error handling.
Add import_action translations and 'invalid' key (lang/en/server/schedule.php, multiple lines) New translations support UI refactor; they do not implement cron validation or backend error handling beyond display text.

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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

🧹 Nitpick comments (6)
lang/en/server/schedule.php (2)

33-34: Good addition: explicit fallback label for invalid cron.
This key enables a safe UI fallback when parsing fails. Consider making the key more specific (e.g., invalid_cron) to avoid generic reuse in unrelated contexts, but this is a nitpick.


109-117: Translations moved and grouped under server/schedule.import_action look consistent. Minor wording/punctuation polish suggested.
The texts read fine; a couple of tiny improvements for clarity and consistency (no spaces inside parentheses, consistent title casing).

Apply this diff:

 'import_action' => [
     'file' => 'File',
     'url' => 'URL',
-    'schedule_help' => 'This should be the raw .json file ( schedule-daily-restart.json )',
+    'schedule_help' => 'This should be the raw .json file (schedule-daily-restart.json)',
     'url_help' => 'URLs must point directly to the raw .json file',
-    'add_url' => 'New URL',
+    'add_url' => 'Add URL',
     'import_failed' => 'Import Failed',
-    'import_success' => 'Import Success',
+    'import_success' => 'Import Successful',
 ],
app/Filament/Server/Resources/ScheduleResource.php (1)

118-126: Escape placeholders and format the date for better UX and safety.
Small hardening: HTML is rendered via HtmlString and placeholders include user timezone; escaping reduces any residual risk. Also propose a more human-readable timestamp.

Apply this diff:

-                    ->description(function (Get $get) {
-                        try {
-                            $nextRun = Utilities::getScheduleNextRunDate($get('cron_minute'), $get('cron_hour'), $get('cron_day_of_month'), $get('cron_month'), $get('cron_day_of_week'))->timezone(auth()->user()->timezone);
-                        } catch (Exception) {
-                            $nextRun = trans('server/schedule.invalid');
-                        }
-
-                        return new HtmlString(trans('server/schedule.cron_body') . '<br>' . trans('server/schedule.cron_timezone', ['timezone' => auth()->user()->timezone, 'next_run' => $nextRun]));
-                    })
+                    ->description(function (Get $get) {
+                        try {
+                            $nextRun = Utilities::getScheduleNextRunDate(
+                                $get('cron_minute'),
+                                $get('cron_hour'),
+                                $get('cron_day_of_month'),
+                                $get('cron_month'),
+                                $get('cron_day_of_week')
+                            )->timezone(auth()->user()->timezone);
+                        } catch (Exception) {
+                            $nextRun = trans('server/schedule.invalid');
+                        }
+
+                        $timezone = e(auth()->user()->timezone);
+                        $nextRunText = $nextRun instanceof Carbon
+                            ? e($nextRun->toDayDateTimeString())
+                            : e($nextRun);
+
+                        return new HtmlString(
+                            trans('server/schedule.cron_body') .
+                            '<br>' .
+                            trans('server/schedule.cron_timezone', [
+                                'timezone' => $timezone,
+                                'next_run' => $nextRunText,
+                            ])
+                        );
+                    })
app/Filament/Components/Actions/ImportScheduleAction.php (3)

46-48: Consider keeping a visible label for accessibility on FileUpload.
hiddenLabel() streamlines the UI, but labels aid screen readers and cognitive load. If you prefer a minimal UI, at least keep an accessible name via the label.

Apply this diff:

-                            FileUpload::make('files')
-                                ->hiddenLabel()
+                            FileUpload::make('files')
+                                ->label(trans('server/schedule.import_action.file'))
                                 ->hint(trans('server/schedule.import_action.schedule_help'))

58-61: Same for Repeater: consider a visible (or at least accessible) label.
Hidden labels can reduce usability. If keeping it hidden, ensure a clear context title elsewhere; alternatively show the label.

Apply this diff:

-                            Repeater::make('urls')
-                                ->hiddenLabel()
+                            Repeater::make('urls')
+                                ->label(trans('server/schedule.import_action.url'))
                                 ->itemLabel(fn (array $state) => str($state['url'])->afterLast('/schedule-')->before('.json')->headline())
                                 ->hint(trans('server/schedule.import_action.url_help'))

67-73: URL validation: endsWith('.json') may reject valid raw URLs with query strings.
Git providers or CDNs often serve raw JSON via URLs like .../file.json?raw=1. endsWith('.json') would fail those. Consider a regex that permits optional query strings.

Apply this diff:

                                     TextInput::make('url')
                                         ->live()
                                         ->label(trans('server/schedule.import_action.url'))
                                         ->url()
-                                        ->endsWith('.json')
+                                        ->rule('regex:/\.json(\?.*)?$/i')
                                         ->validationAttribute(trans('server/schedule.import_action.url')),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f31aa78 and bd40093.

📒 Files selected for processing (4)
  • app/Filament/Components/Actions/ImportScheduleAction.php (2 hunks)
  • app/Filament/Server/Resources/ScheduleResource.php (1 hunks)
  • lang/en/admin/schedule.php (0 hunks)
  • lang/en/server/schedule.php (2 hunks)
💤 Files with no reviewable changes (1)
  • lang/en/admin/schedule.php
🧰 Additional context used
🧬 Code Graph Analysis (1)
app/Filament/Server/Resources/ScheduleResource.php (1)
app/Helpers/Utilities.php (2)
  • Utilities (9-56)
  • getScheduleNextRunDate (39-44)
🔇 Additional comments (5)
lang/en/server/schedule.php (1)

109-117: No non-English locale files for server/schedule.php found
I checked under lang/* and the only server/schedule.php file is the English one you’ve updated. There are no other locale copies, so there are no missing invalid or import_action entries in existing translations.

If you add this file for other languages later, be sure to include those new keys to avoid fallback-to-key.

app/Filament/Server/Resources/ScheduleResource.php (1)

118-126: Great fix: guard cron parsing to prevent 500s in the form.
Catching Exception and returning a localized fallback resolves the original crash scenario in the cron description. This is exactly what was needed for robustness during live editing.

app/Filament/Components/Actions/ImportScheduleAction.php (3)

42-55: Migration to server/schedule.import_action translations looks correct.
Tabs and related strings now consistently reference the server namespace; aligns with the file move.


105-116: Notifications now use the new translation keys. LGTM.
Titles map to server/schedule.import_action.* and align with the moved strings.


42-75: No remaining admin/schedule translation references found
Ran rg -nP "trans\s*\(\s*['\"]admin/schedule" -g '!vendor/**' and confirmed zero matches—all translation keys have been updated.

@Boy132 Boy132 merged commit 42db5b3 into main Aug 18, 2025
25 checks passed
@Boy132 Boy132 deleted the boy132/fix-schedule-translation branch August 18, 2025 21:54
@github-actions github-actions bot locked and limited conversation to collaborators Aug 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cron in schedules throws Server Error 500

3 participants