Skip to content

fix(api): keep plugin config loads side-effect free#2025

Merged
elibosley merged 1 commit into
mainfrom
codex/fix-connect-plugin-install-registration
Jun 13, 2026
Merged

fix(api): keep plugin config loads side-effect free#2025
elibosley merged 1 commit into
mainfrom
codex/fix-connect-plugin-install-registration

Conversation

@elibosley

@elibosley elibosley commented Jun 13, 2026

Copy link
Copy Markdown
Member

Summary

Makes API config loading side-effect free for CLI plugin management commands, so plugin install operations preserve the plugin list they are updating.

Root Cause

loadApiConfig() always ran the stale Connect cleanup when /boot/config/plugins/dynamix.unraid.net.plg was not visible. CLI plugin commands also load API config, so an install command could remove unraid-api-plugin-connect while trying to add it.

During Unraid plugin-manager installation, the Connect .plg may not be committed to /boot/config/plugins yet. That allowed the API package to install and restart successfully while api.json still contained "plugins": [], so the Connect Nest module never loaded.

Change

  • Gates the stale Connect cleanup on environment.IS_MAIN_PROCESS.
  • Keeps CLI config loading side-effect free for plugin management operations.
  • Preserves the existing runtime cleanup behavior when the main API process starts.
  • Adds tests for both CLI-style config loading and main-process cleanup.
  • Builds @unraid/shared before API type-check so workspace package-exported types are current in CI.

Validation

  • pnpm -C api run type-check
  • pnpm -C api exec vitest run src/unraid-api/config/api-config.test.ts
  • pnpm --filter @unraid/connect-plugin test
  • Prior to broadening this fix, installed a patched .plg on root@unraid.local and verified the expected runtime outcome:
    • install output included Added bundled plugin unraid-api-plugin-connect
    • api.json contained "plugins": ["unraid-api-plugin-connect"]
    • unraid-api plugins list reported unraid-api-plugin-connect@file:packages/unraid-api-plugin-connect-4.25.3.tgz
    • /var/log/graphql-api.log showed ConnectPluginModule initialized and Mothership connected

Note: an accidental full pnpm --filter ./api test -- api/src/unraid-api/config/api-config.test.ts run executed the broader API suite and surfaced an existing unrelated metrics spec failure in metrics.resolver.spec.ts; the focused config test passes.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@elibosley, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 1 hour, 30 minutes, and 47 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7bfc6858-f970-4cc5-97ea-4e95a09bb2d0

📥 Commits

Reviewing files that changed from the base of the PR and between 264ddf0 and 7686854.

📒 Files selected for processing (3)
  • api/package.json
  • api/src/unraid-api/config/api-config.module.ts
  • api/src/unraid-api/config/api-config.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-connect-plugin-install-registration

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

@elibosley elibosley marked this pull request as ready for review June 13, 2026 15:14
@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.64%. Comparing base (264ddf0) to head (7686854).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2025   +/-   ##
=======================================
  Coverage   52.63%   52.64%           
=======================================
  Files        1035     1035           
  Lines       72033    72034    +1     
  Branches     8243     8252    +9     
=======================================
+ Hits        37914    37921    +7     
+ Misses      33993    33987    -6     
  Partials      126      126           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

This plugin has been deployed to Cloudflare R2 and is available for testing.
Download it at this URL:

https://preview.dl.unraid.net/unraid-api/tag/PR2025/dynamix.unraid.net.plg

@elibosley elibosley force-pushed the codex/fix-connect-plugin-install-registration branch from 1306102 to 13e35dd Compare June 13, 2026 15:18
@elibosley elibosley changed the title fix(plugin): preserve Connect registration during install fix(api): keep plugin config loads side-effect free Jun 13, 2026
- Keep stale Connect plugin cleanup scoped to the main API process so CLI plugin management commands can load config without mutating plugin registration state.

- Preserve plugin entries during install-time config loads, preventing Connect from being removed before the .plg file exists on disk.

- Add coverage for both CLI and main-process config loading behavior.

- Return Buffer data from config file mocks to match atomically readFile typing.

- Build @unraid/shared before API type-check so exported workspace package types are current in CI.
@elibosley elibosley force-pushed the codex/fix-connect-plugin-install-registration branch from 13e35dd to 7686854 Compare June 13, 2026 15:28
@elibosley elibosley merged commit 3c84326 into main Jun 13, 2026
13 checks passed
@elibosley elibosley deleted the codex/fix-connect-plugin-install-registration branch June 13, 2026 15:44
@github-actions

Copy link
Copy Markdown
Contributor

🔄 PR Merged - Plugin Redirected to Staging

This PR has been merged and the preview plugin has been updated to redirect to the staging version.

For users testing this PR:

  • Your plugin will automatically update to the staging version on the next update check
  • The staging version includes all merged changes from this PR
  • No manual intervention required

Staging URL:

https://preview.dl.unraid.net/unraid-api/dynamix.unraid.net.plg

Thank you for testing! 🚀

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