Skip to content

don't try to bulk update if egg doesn't even have a url - #1887

Merged
rmartinoscar merged 8 commits into
pelican:mainfrom
mristau:UpdateEggBulk
Nov 13, 2025
Merged

don't try to bulk update if egg doesn't even have a url#1887
rmartinoscar merged 8 commits into
pelican:mainfrom
mristau:UpdateEggBulk

Conversation

@mristau

@mristau mristau commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

just checking if update_url is set, before doing bulk update
keeps it from spamming error messages from update_url=null

image

keeps it from spamming error messages from update_url=null
@coderabbitai

coderabbitai Bot commented Nov 10, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Skips eggs with a null update_url during bulk updates, counting skipped items; performs update, cache clearing, and error handling only when update_url exists; notifications now include failed and skipped counts; adds a localization key for the skipped message.

Changes

Cohort / File(s) Summary
Update Egg Bulk Action
app/Filament/Components/Actions/UpdateEggBulkAction.php
Adds a guard checking update_url before attempting updates; introduces a skipped counter; moves update call, success counter, cache forget, exception reporting, and failure counter inside the guarded branch; notification body now includes failed and skipped counts (skipped shown only if > 0); status is warning if any failures, otherwise success.
Localization
lang/en/admin/egg.php
Adds translation key updated_skipped with value :count skipped to represent skipped items in notifications.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant UI as UI / Trigger
    participant Action as UpdateEggBulkAction
    participant Egg as Egg (each)
    participant Updater as EggUpdater::fromUrl
    participant Cache as Cache
    participant Reporter as ExceptionReporter
    participant Notifier as Notification

    UI->>Action: Trigger bulk update
    Action->>Egg: iterate eggs
    Note right of Egg: For each egg
    Egg->>Action: provide update_url
    alt update_url is null
        Action->>Action: skipped_count += 1
    else update_url present
        Action->>Updater: fromUrl(update_url)
        alt success
            Updater-->>Action: success
            Action->>Action: success_count += 1
            Action->>Cache: forget(egg cache key)
        else failure
            Updater-->>Action: throws
            Action->>Action: failure_count += 1
            Action->>Reporter: report(exception)
        end
    end
    Note over Action: after loop, build notification body using failed and skipped counts
    Action->>Notifier: send(status = (failure_count > 0 ? warning : success), body)
Loading

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly describes the main change: adding a check to skip bulk updates for eggs without an update_url, which is the primary focus of the changeset.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose of checking if update_url is set before performing bulk updates and preventing error message spam.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86a4528 and 51382f5.

📒 Files selected for processing (1)
  • app/Filament/Components/Actions/UpdateEggBulkAction.php (2 hunks)
🔇 Additional comments (3)
app/Filament/Components/Actions/UpdateEggBulkAction.php (3)

52-60: LGTM! Clean implementation of the skip logic.

The addition of the $skipped counter and the guard clause correctly prevents update attempts on eggs without an update_url, directly addressing the PR objective. The strict equality check and early continue are appropriate.


76-81: LGTM! Notification body correctly includes skipped count.

The collect/filter/join pattern cleanly builds the notification message to include both failed and skipped counts when present. The syntax error from the previous review has been properly addressed with the closing parenthesis on line 81.


40-84: Excellent implementation of the bulk update action.

The overall logic correctly handles three distinct outcomes (success, failed, skipped) with appropriate counter tracking and notification messaging. The status logic appropriately treats skipped items as non-failures, showing warning only when actual update failures occur. All edge cases (all succeed, all fail, all skip, mixed outcomes) are handled correctly.


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 216a348 and 2e05adf.

📒 Files selected for processing (1)
  • app/Filament/Admin/Resources/Eggs/Pages/ListEggs.php (1 hunks)

Comment thread app/Filament/Admin/Resources/Eggs/Pages/ListEggs.php Outdated
@notAreYouScared

Copy link
Copy Markdown
Member

I'd prefer the change to be in the actual action.

UpdateEggBulkAction.php

@mristau

mristau commented Nov 10, 2025

Copy link
Copy Markdown
Contributor Author

did that now, i was thinking, to filter out all records with no url before doing the action

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 (1)
app/Filament/Components/Actions/UpdateEggBulkAction.php (1)

50-75: Track and report skipped eggs for better user feedback.

Eggs with null update_url are silently skipped and not reflected in the success/failure counts. This could confuse users when the notification shows "Updated X out of Y" without explaining what happened to the remainder.

For example, if 10 eggs are selected but 3 have null update_url, the notification might show "Updated 7 out of 10" without clarifying that 3 were skipped (not failed). If all eggs have null URLs, it would show "Updated 0 out of N" with success status, which is misleading.

Apply this diff to track and report skipped eggs:

         $success = 0;
         $failed = 0;
+        $skipped = 0;
 
         /** @var Egg $egg */
         foreach ($records as $egg) {
             if ($egg->update_url !== null) {
                 try {
                     $eggImporterService->fromUrl($egg->update_url, $egg);
 
                     $success++;
 
                     cache()->forget("eggs.$egg->uuid.update");
                 } catch (Exception $exception) {
                     $failed++;
 
                     report($exception);
                 }
+            } else {
+                $skipped++;
             }
         }
 
         Notification::make()
             ->title(trans_choice('admin/egg.updated', 2, ['count' => $success, 'total' => $records->count()]))
-            ->body($failed > 0 ? trans('admin/egg.updated_failed', ['count' => $failed]) : null)
+            ->body(
+                collect([
+                    $failed > 0 ? trans('admin/egg.updated_failed', ['count' => $failed]) : null,
+                    $skipped > 0 ? trans('admin/egg.updated_skipped', ['count' => $skipped]) : null,
+                ])->filter()->join(' ')
+            )
             ->status($failed > 0 ? 'warning' : 'success')
             ->persistent()
             ->send();

Note: You'll need to add the translation key admin/egg.updated_skipped to your language files.

🧹 Nitpick comments (1)
app/Filament/Components/Actions/UpdateEggBulkAction.php (1)

55-67: Consider using early continue for better readability.

The null check correctly prevents errors when update_url is null. However, using an early continue would reduce nesting depth and improve readability.

Apply this diff to use early continue:

         /** @var Egg $egg */
         foreach ($records as $egg) {
-            if ($egg->update_url !== null) {
-                try {
-                    $eggImporterService->fromUrl($egg->update_url, $egg);
+            if ($egg->update_url === null) {
+                continue;
+            }
 
-                    $success++;
+            try {
+                $eggImporterService->fromUrl($egg->update_url, $egg);
 
-                    cache()->forget("eggs.$egg->uuid.update");
-                } catch (Exception $exception) {
-                    $failed++;
+                $success++;
 
-                    report($exception);
-                }
+                cache()->forget("eggs.$egg->uuid.update");
+            } catch (Exception $exception) {
+                $failed++;
+
+                report($exception);
             }
         }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e05adf and 9a61d3f.

📒 Files selected for processing (1)
  • app/Filament/Components/Actions/UpdateEggBulkAction.php (1 hunks)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a61d3f and 873bd9e.

📒 Files selected for processing (2)
  • app/Filament/Components/Actions/UpdateEggBulkAction.php (1 hunks)
  • lang/en/admin/egg.php (1 hunks)
🔇 Additional comments (3)
lang/en/admin/egg.php (1)

104-104: LGTM!

The translation key follows the existing pattern and is appropriately placed with other update-related messages.

app/Filament/Components/Actions/UpdateEggBulkAction.php (2)

52-52: LGTM!

The skipped counter initialization follows the same pattern as the existing success and failed counters.


56-70: Guard clause effectively prevents null URL errors.

The logic correctly:

  • Skips eggs without update_url instead of attempting (and failing) to update them
  • Tracks skipped eggs separately from failures
  • Clears cache only on successful updates

This addresses the PR objective of preventing error spam when update_url is null.

Comment thread app/Filament/Components/Actions/UpdateEggBulkAction.php
Comment thread app/Filament/Components/Actions/UpdateEggBulkAction.php Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 (1)
app/Filament/Components/Actions/UpdateEggBulkAction.php (1)

73-83: Consider handling the "all skipped" edge case for clearer UX.

The current implementation works correctly, but there's a minor UX consideration: if all eggs are skipped (none have update_url), the notification will show:

  • Title: "0 updated out of X"
  • Body: "X skipped"
  • Status: success (green)

While technically correct, you might consider adding a check similar to lines 41-48 to provide more specific feedback when all eggs are skipped, such as an info-level notification stating no eggs had update URLs. This would make the outcome clearer to users.

Example implementation:

if ($success === 0 && $failed === 0 && $skipped > 0) {
    Notification::make()
        ->title(trans('admin/egg.all_skipped'))
        ->body(trans('admin/egg.all_skipped_description'))
        ->info()
        ->send();
    
    return;
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6a0b6b0 and 86a4528.

📒 Files selected for processing (1)
  • app/Filament/Components/Actions/UpdateEggBulkAction.php (2 hunks)
🔇 Additional comments (3)
app/Filament/Components/Actions/UpdateEggBulkAction.php (3)

52-52: LGTM! Counter initialization is correct.

The $skipped counter is properly initialized alongside the existing $success and $failed counters.


56-59: Excellent! This directly addresses the PR objective.

The null check for update_url prevents attempting bulk updates on eggs without URLs, eliminating the error spam mentioned in the PR description. The logic is clean:

  • Uses strict comparison (===)
  • Increments the skipped counter
  • Continues to the next egg without processing

75-80: LGTM! Notification body correctly includes skipped count.

The notification body now properly displays both failed and skipped counts when applicable:

  • Conditionally includes messages only when counts > 0
  • Filters null values and joins messages with spaces
  • Syntax is correct (closing parenthesis properly placed, as noted in previous review)

The user will see clear feedback about what happened during the bulk update.

@rmartinoscar
rmartinoscar merged commit 20cb785 into pelican:main Nov 13, 2025
25 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 13, 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.

4 participants