Skip to content

Conversation

@pujitm
Copy link
Member

@pujitm pujitm commented Jul 23, 2025

Prevent extraneous fields from migrating to connect.json from myservers.cfg

Summary by CodeRabbit

  • Chores

    • Updated configuration file to remove unused fields and replace the API key placeholder with a more generic string.
  • Refactor

    • Improved configuration validation to automatically remove any unrecognized properties.

this also prevents extraneous fields from migrating from myservers.cfg
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 23, 2025

Walkthrough

The connect.json configuration file was updated to replace the API key placeholder and remove several fields related to tokens and versioning. Additionally, the ConnectConfigPersister class's validation logic was updated to use property whitelisting, ensuring only explicitly defined fields are retained during validation.

Changes

File(s) Change Summary
api/dev/configs/connect.json Replaced API key placeholder; removed fields: version, extraOrigins, sandbox, accesstoken, idtoken, refreshtoken, ssoSubIds.
packages/unraid-api-plugin-connect/src/config/config.persistence.ts Updated validate method to use { whitelist: true } in validation, stripping unknown fields.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ConfigPersister
    participant Validator

    User->>ConfigPersister: Provide config object
    ConfigPersister->>Validator: validateOrReject(config, { whitelist: true })
    Validator-->>ConfigPersister: Validated config (unknown fields stripped)
    ConfigPersister-->>User: Return validated config or throw error
Loading

Estimated code review effort

2 (~15 minutes)

Possibly related PRs

Suggested reviewers

  • mdatelle
  • elibosley

Poem

Fields removed, the config's light,
Whitelisted now, the keys are right.
Tokens gone, the code is clean,
Simpler flows behind the scene.
Reviewers, gather—let's inspect,
For tidy configs, we connect!


📜 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 fee7d46 and 34c7295.

📒 Files selected for processing (2)
  • api/dev/configs/connect.json (1 hunks)
  • packages/unraid-api-plugin-connect/src/config/config.persistence.ts (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 (3)
📓 Common learnings
Learnt from: pujitm
PR: unraid/api#1211
File: api/src/unraid-api/graph/connect/connect-settings.service.ts:0-0
Timestamp: 2025-03-14T19:22:11.839Z
Learning: In the Unraid API project, input validation should happen at the store layer, not in service methods like ConnectSettingsService, to maintain proper separation of concerns.
Learnt from: elibosley
PR: unraid/api#969
File: web/justfile:7-9
Timestamp: 2024-11-27T15:30:02.252Z
Learning: In the Unraid Connect project, the different implementations of the `setup` commands in `web/justfile` and `api/justfile` are intentional and correct behavior.
Learnt from: elibosley
PR: unraid/api#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: unraid/api#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.
Learnt from: pujitm
PR: unraid/api#1211
File: api/src/graphql/schema/types/connect/connect.graphql:142-146
Timestamp: 2025-03-14T16:10:38.562Z
Learning: The updateApiSettings mutation in api/src/unraid-api/graph/connect/connect.resolver.ts is protected with the @UsePermissions decorator that requires UPDATE permission on the CONFIG resource.
Learnt from: pujitm
PR: unraid/api#1211
File: api/src/unraid-api/graph/connect/connect-settings.service.ts:0-0
Timestamp: 2025-03-14T16:09:53.997Z
Learning: Validation and error handling for settings and configurations should be handled in the store layer, not in service layers like ConnectSettingsService.
Learnt from: pujitm
PR: unraid/api#1352
File: packages/unraid-api-plugin-generator/src/create-plugin.ts:91-112
Timestamp: 2025-04-21T18:27:36.482Z
Learning: For utility functions like file operations in api plugin generators, pujitm prefers minimal error handling rather than verbose try/catch blocks for each operation, as errors will propagate properly to higher level error handlers.
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.

packages/unraid-api-plugin-connect/src/config/config.persistence.ts (3)

Learnt from: pujitm
PR: #1211
File: api/src/graphql/schema/types/connect/connect.graphql:142-146
Timestamp: 2025-03-14T16:10:38.562Z
Learning: The updateApiSettings mutation in api/src/unraid-api/graph/connect/connect.resolver.ts is protected with the @UsePermissions decorator that requires UPDATE permission on the CONFIG resource.

Learnt from: pujitm
PR: #1211
File: api/src/unraid-api/graph/connect/connect-settings.service.ts:0-0
Timestamp: 2025-03-14T19:22:11.839Z
Learning: In the Unraid API project, input validation should happen at the store layer, not in service methods like ConnectSettingsService, to maintain proper separation of concerns.

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.

🧰 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 (3)
📓 Common learnings
Learnt from: pujitm
PR: unraid/api#1211
File: api/src/unraid-api/graph/connect/connect-settings.service.ts:0-0
Timestamp: 2025-03-14T19:22:11.839Z
Learning: In the Unraid API project, input validation should happen at the store layer, not in service methods like ConnectSettingsService, to maintain proper separation of concerns.
Learnt from: elibosley
PR: unraid/api#969
File: web/justfile:7-9
Timestamp: 2024-11-27T15:30:02.252Z
Learning: In the Unraid Connect project, the different implementations of the `setup` commands in `web/justfile` and `api/justfile` are intentional and correct behavior.
Learnt from: elibosley
PR: unraid/api#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: unraid/api#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.
Learnt from: pujitm
PR: unraid/api#1211
File: api/src/graphql/schema/types/connect/connect.graphql:142-146
Timestamp: 2025-03-14T16:10:38.562Z
Learning: The updateApiSettings mutation in api/src/unraid-api/graph/connect/connect.resolver.ts is protected with the @UsePermissions decorator that requires UPDATE permission on the CONFIG resource.
Learnt from: pujitm
PR: unraid/api#1211
File: api/src/unraid-api/graph/connect/connect-settings.service.ts:0-0
Timestamp: 2025-03-14T16:09:53.997Z
Learning: Validation and error handling for settings and configurations should be handled in the store layer, not in service layers like ConnectSettingsService.
Learnt from: pujitm
PR: unraid/api#1352
File: packages/unraid-api-plugin-generator/src/create-plugin.ts:91-112
Timestamp: 2025-04-21T18:27:36.482Z
Learning: For utility functions like file operations in api plugin generators, pujitm prefers minimal error handling rather than verbose try/catch blocks for each operation, as errors will propagate properly to higher level error handlers.
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.

packages/unraid-api-plugin-connect/src/config/config.persistence.ts (3)

Learnt from: pujitm
PR: #1211
File: api/src/graphql/schema/types/connect/connect.graphql:142-146
Timestamp: 2025-03-14T16:10:38.562Z
Learning: The updateApiSettings mutation in api/src/unraid-api/graph/connect/connect.resolver.ts is protected with the @UsePermissions decorator that requires UPDATE permission on the CONFIG resource.

Learnt from: pujitm
PR: #1211
File: api/src/unraid-api/graph/connect/connect-settings.service.ts:0-0
Timestamp: 2025-03-14T19:22:11.839Z
Learning: In the Unraid API project, input validation should happen at the store layer, not in service methods like ConnectSettingsService, to maintain proper separation of concerns.

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.

⏰ 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 Web App
  • GitHub Check: Build API
  • GitHub Check: Test API
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
api/dev/configs/connect.json (2)

5-5: API key placeholder updated appropriately.

The longer placeholder makes it more obvious this is a test value that needs replacement.


11-12: Configuration cleanup aligns with PR objectives.

The removal of extraneous fields like version, extraOrigins, sandbox, accesstoken, idtoken, refreshtoken, and ssoSubIds successfully demonstrates the fix for preventing field migration from myservers.cfg.

packages/unraid-api-plugin-connect/src/config/config.persistence.ts (1)

58-58: Whitelist validation correctly implements the fix.

Adding { whitelist: true } ensures that only properties explicitly defined in the MyServersConfig schema are retained during validation, effectively preventing extraneous fields from migrating from myservers.cfg to connect.json.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.

@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/PR1538/dynamix.unraid.net.plg

@pujitm pujitm merged commit 45bd736 into main Jul 23, 2025
11 checks passed
@pujitm pujitm deleted the fix/connect-migration branch July 23, 2025 17:55
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.

2 participants