Skip to content

Feature: Add support for user-configurable egg/nests index file.#2287

Open
JorgenVatle wants to merge 3 commits intopelican-dev:mainfrom
JorgenVatle:make-egg-repository-configurable
Open

Feature: Add support for user-configurable egg/nests index file.#2287
JorgenVatle wants to merge 3 commits intopelican-dev:mainfrom
JorgenVatle:make-egg-repository-configurable

Conversation

@JorgenVatle
Copy link
Copy Markdown

Bit of a feature suggestion here. Noticed the URL used to build up the list of suggested official eggs was hardcoded. This pull request moves the URL into the application config with an optional environment override.

We have a number of custom egg configs that we want to offer to our admins. Copy pasting URLs for those was getting a little tedious, especially if one is accidentally deleted and you don't have the original URL handy.

This should address that, plus open up for users to make eggs discoverable through the import menu, or limit which nests should appear in the menu.

Not sure what you have on the roadmap, but I'd be happy to work on a follow-up to this where nests can be merged with a user-provided URL instead of replaced outright.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3ff64bfc-75fd-40fa-85a3-bd2588ece90c

📥 Commits

Reviewing files that changed from the base of the PR and between 6c9d12b and 6dac9d1.

📒 Files selected for processing (1)
  • config/panel.php
✅ Files skipped from review due to trivial changes (1)
  • config/panel.php

📝 Walkthrough

Walkthrough

The egg index source URL is now configurable via panel.egg.nest_url (from PANEL_EGG_NEST_URL). UpdateEggIndexCommand reads config('panel.egg.nest_url') instead of a hardcoded GitHub raw URL; parsing, caching, and error handling remain unchanged.

Changes

Cohort / File(s) Summary
Configuration
config/panel.php
Added new egg.nest_url configuration key populated from PANEL_EGG_NEST_URL with a default Pelican Eggs pelican.json URL.
Command
app/Console/Commands/Egg/UpdateEggIndexCommand.php
Replaced hardcoded raw GitHub URL with config('panel.egg.nest_url') as the HTTP request source; JSON parsing, index assembly, caching, and error handling unchanged.
🚥 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
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding user-configurable support for the egg/nests index file URL.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation for making the hardcoded egg index URL configurable and the benefits it provides.

✏️ Tip: You can configure your own custom pre-merge checks in the 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.

@JorgenVatle
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Copy link
Copy Markdown

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/Console/Commands/Egg/UpdateEggIndexCommand.php`:
- Line 16: The UpdateEggIndexCommand currently assumes the HTTP response
assigned to $data contains a nested structure (e.g. $data['nests']) which can
throw if the JSON is malformed; validate the schema after the GET: check that
$data is an array, that 'nests' exists and is an array, and that each nest
contains an 'eggs' array with the expected keys before indexing; in the
UpdateEggIndexCommand replace direct indexing of $data['nests']/$nest['eggs']
with guarded checks (using is_array/array_key_exists or Laravel helpers like
Arr::get/data_get), log a clear error and abort or skip when the shape is
invalid, and default to an empty list to avoid breaking downstream egg
selection.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a0c7d71a-06c8-475d-bb74-c2edb04b8b21

📥 Commits

Reviewing files that changed from the base of the PR and between b693d0e and 75640a7.

📒 Files selected for processing (2)
  • app/Console/Commands/Egg/UpdateEggIndexCommand.php
  • config/panel.php

{
try {
$data = Http::timeout(5)->connectTimeout(1)->get('https://raw.githubusercontent.com/pelican-eggs/pelican-eggs.github.io/refs/heads/main/content/pelican.json')->throw()->json();
$data = Http::timeout(5)->connectTimeout(1)->get(config('panel.egg.index_url'))->throw()->json();
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Mar 30, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Validate response schema before indexing nested keys.

With a user-configurable URL, non-conforming JSON is now much more likely. Accessing $data['nests'] (and deeper keys) without guards can fail at runtime and break downstream egg selection that assumes a strict cached shape.

🔧 Proposed hardening
-            $data = Http::timeout(5)->connectTimeout(1)->get(config('panel.egg.index_url'))->throw()->json();
+            $data = Http::timeout(5)->connectTimeout(1)->get(config('panel.egg.index_url'))->throw()->json();
         } catch (Exception $exception) {
             $this->error($exception->getMessage());

             return 1;
         }
+
+        if (!is_array($data) || !isset($data['nests']) || !is_array($data['nests'])) {
+            $this->error('Invalid egg index payload: expected top-level "nests" array.');
+            return 1;
+        }

         $index = [];
         foreach ($data['nests'] as $nest) {
+            if (
+                !is_array($nest) ||
+                !isset($nest['nest_type'], $nest['Eggs']) ||
+                !is_array($nest['Eggs'])
+            ) {
+                continue;
+            }
             $nestName = $nest['nest_type'];
@@
             $nestEggs = [];
             foreach ($nest['Eggs'] as $egg) {
+                if (
+                    !is_array($egg) ||
+                    !isset($egg['download_url'], $egg['egg']['name'])
+                ) {
+                    continue;
+                }
                 $eggName = $egg['egg']['name'];
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/Console/Commands/Egg/UpdateEggIndexCommand.php` at line 16, The
UpdateEggIndexCommand currently assumes the HTTP response assigned to $data
contains a nested structure (e.g. $data['nests']) which can throw if the JSON is
malformed; validate the schema after the GET: check that $data is an array, that
'nests' exists and is an array, and that each nest contains an 'eggs' array with
the expected keys before indexing; in the UpdateEggIndexCommand replace direct
indexing of $data['nests']/$nest['eggs'] with guarded checks (using
is_array/array_key_exists or Laravel helpers like Arr::get/data_get), log a
clear error and abort or skip when the shape is invalid, and default to an empty
list to avoid breaking downstream egg selection.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This was an issue prior to the changes introduced here. I'd like to follow up with a separate PR to emit less obscure validation errors if the received JSON is malformed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@JorgenVatle, that's fair — this concern predates the changes in this PR. Would you like me to open a GitHub issue to track the follow-up validation work so it doesn't get lost?

{
try {
$data = Http::timeout(5)->connectTimeout(1)->get('https://raw.githubusercontent.com/pelican-eggs/pelican-eggs.github.io/refs/heads/main/content/pelican.json')->throw()->json();
$data = Http::timeout(5)->connectTimeout(1)->get(config('panel.egg.nest_url'))->throw()->json();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Move the config value to panel.cdn.egg_index_url.

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.

2 participants