Skip to content

Conversation

@elibosley
Copy link
Member

@elibosley elibosley commented Jul 21, 2025

Summary by CodeRabbit

  • New Features

    • Updated configuration to enable WAN access, set custom ports, and add new fields such as version and sandbox mode.
  • Bug Fixes

    • Improved log rotation reliability by directly managing log file size and truncation every 20 minutes, with enhanced error handling and logging.
  • Chores

    • Removed legacy log rotation configuration files and related test cases to streamline maintenance.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 21, 2025

Walkthrough

This change removes the custom logrotate configuration management system, including its modification class, patch file, and related tests. Instead, log rotation is now handled directly within the service by truncating the log file if it exceeds 5MB, checked every 20 minutes. The configuration file is also updated with new and modified fields.

Changes

File(s) Change Summary
api/src/unraid-api/unraid-file-modifier/modifications/log-rotate.modification.ts Deleted: Removed the LogRotateModification class and its logic.
api/src/unraid-api/unraid-file-modifier/modifications/patches/log-rotate.patch Deleted: Removed the logrotate configuration patch file.
api/src/unraid-api/unraid-file-modifier/modifications/test/fixtures/... Deleted: Removed test fixture file for logrotate last-download-time.
api/src/unraid-api/unraid-file-modifier/modifications/test/generic-modification.spec.ts Updated: Removed LogRotateModification test case and related imports.
api/src/unraid-api/cron/log-rotate.service.ts Refactored: Now directly checks and truncates log file if over 5MB, every 20 minutes.
api/dev/configs/connect.json Updated: Modified and added configuration fields, including WAN access, ports, and new properties.

Sequence Diagram(s)

sequenceDiagram
    participant Cron as Cron Scheduler
    participant LogRotateService as LogRotateService
    participant FS as File System

    Cron->>LogRotateService: Trigger handleCron() every 20 minutes
    LogRotateService->>FS: stat('/var/log/graphql-api.log')
    alt File exists and size > 5MB
        LogRotateService->>FS: truncate('/var/log/graphql-api.log')
        LogRotateService->>LogRotateService: Log truncation success
    else File does not exist
        LogRotateService->>LogRotateService: Log file missing, skip truncation
    else Other error
        LogRotateService->>LogRotateService: Log error
    end
Loading

Estimated code review effort

2 (~15 minutes)

Possibly related PRs

Suggested reviewers

  • mdatelle
  • pujitm

Poem

Logs once rotated with config and care,
Now trimmed by size, with cycles to spare.
Old classes and patches swept away,
Simpler checks keep bloat at bay.
A cron job hums, the configs shine—
Clean, concise, and by design!


🪧 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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

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

🧹 Nitpick comments (2)
api/dev/configs/connect.json (2)

2-3: Opening WAN access in a dev profile—double-check exposure

Setting "wanaccess": true and "wanport": 8443 makes the dev API reachable from outside the LAN.
Confirm this is intentional, that firewalls are configured, and that no sensitive data is reachable from an unauthenticated path.
If WAN exposure is only needed in prod, consider keeping the dev profile disabled or gating it behind an env-var toggle.


14-14: Prefer boolean for sandbox flag

Using the string "yes" can cause truthiness bugs or schema validation failures. A boolean conveys intent more clearly.

-  "sandbox": "yes",
+  "sandbox": true,
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a050ca5 and 4333bbb.

📒 Files selected for processing (1)
  • api/dev/configs/connect.json (1 hunks)
📓 Path-based instructions (1)
api/**/*

📄 CodeRabbit Inference Engine (.cursor/rules/api-rules.mdc)

api/**/*: Use pnpm as the only package manager
Always run scripts from api/package.json unless specifically requested otherwise

Files:

  • api/dev/configs/connect.json
🧠 Learnings (2)
📓 Common learnings
Learnt from: elibosley
PR: unraid/api#1082
File: api/src/unraid-api/unraid-file-modifier/modifications/log-rotate.modification.ts:33-37
Timestamp: 2025-01-29T16:36:04.777Z
Learning: In the Unraid API, FileModification implementations (like LogRotateModification) don't need to handle errors internally as error handling is managed at the UnraidFileModifierService level.
Learnt from: elibosley
PR: unraid/api#1082
File: api/src/unraid-api/unraid-file-modifier/modifications/log-rotate.modification.ts:33-37
Timestamp: 2025-01-29T16:36:04.777Z
Learning: The UnraidFileModifierService in the Unraid API provides comprehensive error handling for all FileModification implementations. It includes try/catch blocks, detailed error logging, and safe rollback mechanisms. Individual FileModification implementations (like LogRotateModification) should allow errors to propagate to this service layer rather than handling them internally.
api/dev/configs/connect.json (2)

Learnt from: elibosley
PR: #1425
File: api/dev/configs/connect.json:5-13
Timestamp: 2025-06-20T20:50:14.050Z
Learning: Connect configuration files like api/dev/configs/connect.json use their own naming conventions (e.g., apikey, accesstoken, idtoken, refreshtoken) as implementation details, and these should not be changed to follow general camelCase patterns.

Learnt from: pujitm
PR: #1211
File: web/codegen.ts:14-14
Timestamp: 2025-03-12T13:35:43.900Z
Learning: The JSON scalar type in web/codegen.ts was temporarily changed from 'string' to 'any' for compatibility with JsonForms integration. This change facilitates the implementation of the Connect settings web component.

🪛 Gitleaks (8.27.2)
api/dev/configs/connect.json

5-5: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🧰 Additional context used
📓 Path-based instructions (1)
api/**/*

📄 CodeRabbit Inference Engine (.cursor/rules/api-rules.mdc)

api/**/*: Use pnpm as the only package manager
Always run scripts from api/package.json unless specifically requested otherwise

Files:

  • api/dev/configs/connect.json
🧠 Learnings (2)
📓 Common learnings
Learnt from: elibosley
PR: unraid/api#1082
File: api/src/unraid-api/unraid-file-modifier/modifications/log-rotate.modification.ts:33-37
Timestamp: 2025-01-29T16:36:04.777Z
Learning: In the Unraid API, FileModification implementations (like LogRotateModification) don't need to handle errors internally as error handling is managed at the UnraidFileModifierService level.
Learnt from: elibosley
PR: unraid/api#1082
File: api/src/unraid-api/unraid-file-modifier/modifications/log-rotate.modification.ts:33-37
Timestamp: 2025-01-29T16:36:04.777Z
Learning: The UnraidFileModifierService in the Unraid API provides comprehensive error handling for all FileModification implementations. It includes try/catch blocks, detailed error logging, and safe rollback mechanisms. Individual FileModification implementations (like LogRotateModification) should allow errors to propagate to this service layer rather than handling them internally.
api/dev/configs/connect.json (2)

Learnt from: elibosley
PR: #1425
File: api/dev/configs/connect.json:5-13
Timestamp: 2025-06-20T20:50:14.050Z
Learning: Connect configuration files like api/dev/configs/connect.json use their own naming conventions (e.g., apikey, accesstoken, idtoken, refreshtoken) as implementation details, and these should not be changed to follow general camelCase patterns.

Learnt from: pujitm
PR: #1211
File: web/codegen.ts:14-14
Timestamp: 2025-03-12T13:35:43.900Z
Learning: The JSON scalar type in web/codegen.ts was temporarily changed from 'string' to 'any' for compatibility with JsonForms integration. This change facilitates the implementation of the Connect settings web component.

🪛 Gitleaks (8.27.2)
api/dev/configs/connect.json

5-5: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build API
  • GitHub Check: Build Web App
  • GitHub Check: Test API
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
api/dev/configs/connect.json (1)

12-13: Verify extraOrigins shape matches the consumer code

The field holds a comma-separated string. If the consuming code expects an array (common for CORS/Origin lists), this will break parsing.

-  "extraOrigins": "https://google.com,https://test.com",
+  "extraOrigins": ["https://google.com", "https://test.com"],

Please confirm the expected type and adjust accordingly.

Comment on lines +5 to +6
"apikey": "test-api-key-12345",
"localApiKey": "_______________________LOCAL_API_KEY_HERE_________________________",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Possible secret committed – replace with placeholder or env var

"apikey": "test-api-key-12345" is flagged by gitleaks. Even if it’s a dummy value, storing any key-looking string in VCS trains developers to commit real ones later.

-  "apikey": "test-api-key-12345",
+  "apikey": "<REPLACE_ME>",

Ideally pull this from an environment variable at runtime instead of hard-coding.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"apikey": "test-api-key-12345",
"localApiKey": "_______________________LOCAL_API_KEY_HERE_________________________",
"apikey": "<REPLACE_ME>",
"localApiKey": "_______________________LOCAL_API_KEY_HERE_________________________",
🧰 Tools
🪛 Gitleaks (8.27.2)

5-5: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🤖 Prompt for AI Agents
In api/dev/configs/connect.json at lines 5 to 6, the "apikey" field contains a
hard-coded key string which is flagged as a possible secret. Replace the
hard-coded "apikey" value with a placeholder string or remove it entirely, and
modify the application code to load the actual API key from an environment
variable at runtime instead of storing it in the config file.

@github-actions
Copy link
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/PR1530/dynamix.unraid.net.plg

Comment on lines +19 to +20
this.logger.debug(`Log file size (${stats.size} bytes) exceeds limit, truncating`);
await execa('truncate', ['-s', '0', this.logFilePath]);
Copy link
Member

Choose a reason for hiding this comment

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

does the log before truncating immediately get voided into the aether?

Copy link
Member Author

Choose a reason for hiding this comment

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

lmao yes.

@elibosley elibosley merged commit 0a18b38 into main Jul 22, 2025
11 checks passed
@elibosley elibosley deleted the fix/truncate-logs branch July 22, 2025 18:40
elibosley pushed a commit that referenced this pull request Jul 28, 2025
🤖 I have created a release *beep* *boop*
---


## [4.11.0](v4.10.0...v4.11.0)
(2025-07-28)


### Features

* tailwind v4 ([#1522](#1522))
([2c62e0a](2c62e0a))
* **web:** install and configure nuxt ui
([#1524](#1524))
([407585c](407585c))


### Bug Fixes

* add missing breakpoints
([#1535](#1535))
([f5352e3](f5352e3))
* border color incorrect in tailwind
([#1544](#1544))
([f14b74a](f14b74a))
* **connect:** omit extraneous fields during connect config validation
([#1538](#1538))
([45bd736](45bd736))
* **deps:** pin dependencies
([#1528](#1528))
([a74d935](a74d935))
* **deps:** pin dependency @nuxt/ui to 3.2.0
([#1532](#1532))
([8279531](8279531))
* **deps:** update all non-major dependencies
([#1510](#1510))
([1a8da6d](1a8da6d))
* **deps:** update all non-major dependencies
([#1520](#1520))
([e2fa648](e2fa648))
* inject Tailwind CSS into client entry point
([#1537](#1537))
([86b6c4f](86b6c4f))
* make settings grid responsive
([#1463](#1463))
([9dfdb8d](9dfdb8d))
* **notifications:** gracefully handle & mask invalid notifications
([#1529](#1529))
([05056e7](05056e7))
* truncate log files when they take up more than 5mb of space
([#1530](#1530))
([0a18b38](0a18b38))
* use async for primary file read/writes
([#1531](#1531))
([23b2b88](23b2b88))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
mdatelle pushed a commit that referenced this pull request Jul 30, 2025
🤖 I have created a release *beep* *boop*
---


## [4.11.0](v4.10.0...v4.11.0)
(2025-07-28)


### Features

* tailwind v4 ([#1522](#1522))
([2c62e0a](2c62e0a))
* **web:** install and configure nuxt ui
([#1524](#1524))
([407585c](407585c))


### Bug Fixes

* add missing breakpoints
([#1535](#1535))
([f5352e3](f5352e3))
* border color incorrect in tailwind
([#1544](#1544))
([f14b74a](f14b74a))
* **connect:** omit extraneous fields during connect config validation
([#1538](#1538))
([45bd736](45bd736))
* **deps:** pin dependencies
([#1528](#1528))
([a74d935](a74d935))
* **deps:** pin dependency @nuxt/ui to 3.2.0
([#1532](#1532))
([8279531](8279531))
* **deps:** update all non-major dependencies
([#1510](#1510))
([1a8da6d](1a8da6d))
* **deps:** update all non-major dependencies
([#1520](#1520))
([e2fa648](e2fa648))
* inject Tailwind CSS into client entry point
([#1537](#1537))
([86b6c4f](86b6c4f))
* make settings grid responsive
([#1463](#1463))
([9dfdb8d](9dfdb8d))
* **notifications:** gracefully handle & mask invalid notifications
([#1529](#1529))
([05056e7](05056e7))
* truncate log files when they take up more than 5mb of space
([#1530](#1530))
([0a18b38](0a18b38))
* use async for primary file read/writes
([#1531](#1531))
([23b2b88](23b2b88))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

4 participants