[codex] fix dependency audit issues#2028
Conversation
|
Warning Review limit reached
More reviews will be available in 2 hours, 31 minutes, and 17 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 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 configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (31)
WalkthroughDependency versions are bumped across all monorepo workspaces (api, plugin packages, unraid-ui, web, plugin). A new ChangesMonorepo dependency upgrades and test fix
pnpm audit tooling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
🚀 Storybook has been deployed to staging: https://unraid-ui-storybook-staging.unraid-workers.workers.dev |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@api/src/unraid-api/graph/resolvers/unraid-plugins/unraid-plugins.service.spec.ts`:
- Around line 170-175: Replace the mock ConfigService object creation that uses
the `as unknown as ConfigService` casting pattern with the `vi.spyOn()` approach
to maintain type safety and avoid unsafe casting. The current pattern at the
configService initialization violates type safety guidelines. Instead of
creating a mock object and casting it, use the spy approach demonstrated in the
existing test setup to properly mock the ConfigService without bypassing
TypeScript's type checking. Apply this fix consistently wherever this pattern
appears in the test file.
In `@scripts/pnpm-audit.mjs`:
- Around line 9-13: The spawnSync call for the pnpm audit command in the audit
function does not specify an explicit maxBuffer option, which defaults to 1 MB
and can be exceeded by large audit payloads, causing stdout truncation and
JSON.parse failures. Add a maxBuffer property to the options object passed to
spawnSync with a significantly larger value (such as 10 MB or higher) to
accommodate large audit output without truncation.
In `@unraid-ui/package.json`:
- Line 89: The devDependencies for ajv has been upgraded to 8.20.0, but the
peerDependencies.ajv is still pinned to 8.17.1, creating a version mismatch.
Update the peerDependencies.ajv version from 8.17.1 to 8.20.0 to align with the
upgraded devDependencies version and match what is being consumed in
web/package.json.
🪄 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: 869d8a80-ee9e-4352-9190-bb46f85b2e2b
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (11)
api/package.jsonapi/src/unraid-api/graph/resolvers/unraid-plugins/unraid-plugins.service.spec.tspackage.jsonpackages/unraid-api-plugin-connect/package.jsonpackages/unraid-api-plugin-generator/package.jsonpackages/unraid-api-plugin-health/package.jsonpackages/unraid-shared/package.jsonplugin/package.jsonscripts/pnpm-audit.mjsunraid-ui/package.jsonweb/package.json
| const configService = { | ||
| get: vi.fn().mockReturnValue({ | ||
| 'dynamix-base': join(tempDir, 'missing', 'dynamix-base'), | ||
| }), | ||
| } as unknown as ConfigService; | ||
| const configuredService = new UnraidPluginsService(configService); |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -nP "as\\s+unknown\\s+as\\s+ConfigService|\\bas\\s+any\\b" api/src/unraid-api/graph/resolvers/unraid-plugins/unraid-plugins.service.spec.tsRepository: unraid/api
Length of output: 286
🏁 Script executed:
# Get the full context around lines 170-175 and examine surrounding test structure
sed -n '150,180p' api/src/unraid-api/graph/resolvers/unraid-plugins/unraid-plugins.service.spec.ts | cat -nRepository: unraid/api
Length of output: 1650
🏁 Script executed:
# Check the imports and ConfigService definition in this test file
head -40 api/src/unraid-api/graph/resolvers/unraid-plugins/unraid-plugins.service.spec.ts | cat -nRepository: unraid/api
Length of output: 1690
🏁 Script executed:
# Verify all instances of casting pattern and understand test structure
grep -n -B2 -A2 "as unknown as" api/src/unraid-api/graph/resolvers/unraid-plugins/unraid-plugins.service.spec.tsRepository: unraid/api
Length of output: 1024
🏁 Script executed:
# Check ConfigService definition and whether it can be instantiated directly
fd -t f ConfigService.ts$ | head -5 | xargs cat -n 2>/dev/null | head -80Repository: unraid/api
Length of output: 36
Remove unnecessary casting of mock ConfigService
The as unknown as ConfigService pattern bypasses type safety and violates the coding guideline to avoid casting. Use direct instantiation with vi.spyOn() instead, as demonstrated by the existing test setup at line 34.
This casting pattern appears at multiple locations in the test file (lines 157, 174, 193) and should be addressed consistently.
Example fix
- const configService = {
- get: vi.fn().mockReturnValue({
- 'dynamix-base': join(tempDir, 'missing', 'dynamix-base'),
- }),
- } as unknown as ConfigService;
+ const configService = new ConfigService();
+ vi.spyOn(configService, 'get').mockReturnValue({
+ 'dynamix-base': join(tempDir, 'missing', 'dynamix-base'),
+ });
const configuredService = new UnraidPluginsService(configService);📝 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.
| const configService = { | |
| get: vi.fn().mockReturnValue({ | |
| 'dynamix-base': join(tempDir, 'missing', 'dynamix-base'), | |
| }), | |
| } as unknown as ConfigService; | |
| const configuredService = new UnraidPluginsService(configService); | |
| const configService: Partial<ConfigService> = { | |
| get: vi.fn().mockReturnValue({ | |
| 'dynamix-base': join(tempDir, 'missing', 'dynamix-base'), | |
| }), | |
| }; | |
| const configuredService = new UnraidPluginsService(configService as ConfigService); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@api/src/unraid-api/graph/resolvers/unraid-plugins/unraid-plugins.service.spec.ts`
around lines 170 - 175, Replace the mock ConfigService object creation that uses
the `as unknown as ConfigService` casting pattern with the `vi.spyOn()` approach
to maintain type safety and avoid unsafe casting. The current pattern at the
configService initialization violates type safety guidelines. Instead of
creating a mock object and casting it, use the spy approach demonstrated in the
existing test setup to properly mock the ConfigService without bypassing
TypeScript's type checking. Apply this fix consistently wherever this pattern
appears in the test file.
Source: Coding guidelines
| const audit = spawnSync('pnpm', ['audit', '--json', ...args], { | ||
| cwd, | ||
| encoding: 'utf8', | ||
| stdio: ['ignore', 'pipe', 'pipe'], | ||
| }); |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
What is the default maxBuffer for Node.js child_process.spawnSync, and what happens when stdout/stderr exceed that limit?
💡 Result:
The default maxBuffer for child_process.spawnSync in Node.js is 1024 * 1024 bytes (1 MB) [1][2]. When the amount of data written to stdout or stderr exceeds this limit, the child process is terminated, and any accumulated output is truncated [1][3]. The method will return an object containing the process's exit information, and the error property will typically reflect that the buffer limit was exceeded (often resulting in an ENOBUFS error) [4].
Citations:
- 1: https://nodejs.org/docs/latest-v26.x/api/child_process.html
- 2: https://github.com/nodejs/node/blob/main/doc/api/child_process.md
- 3: https://beta.docs.nodejs.org/child_process.html
- 4:
spawnSync()'smaxBufferoption is not ignored withstdio[3]: 'ignore'nodejs/node#52338
🏁 Script executed:
cat -n scripts/pnpm-audit.mjs | head -40Repository: unraid/api
Length of output: 1379
🏁 Script executed:
cat -n scripts/pnpm-audit.mjs | tail -n +40Repository: unraid/api
Length of output: 6133
Set an explicit maxBuffer for spawnSync audit output.
The default maxBuffer limit of 1 MB can be exceeded by large audit payloads, causing stdout to be truncated and JSON.parse to fail silently on line 22.
Suggested fix
const audit = spawnSync('pnpm', ['audit', '--json', ...args], {
cwd,
encoding: 'utf8',
+ maxBuffer: 10 * 1024 * 1024,
stdio: ['ignore', 'pipe', 'pipe'],
});📝 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.
| const audit = spawnSync('pnpm', ['audit', '--json', ...args], { | |
| cwd, | |
| encoding: 'utf8', | |
| stdio: ['ignore', 'pipe', 'pipe'], | |
| }); | |
| const audit = spawnSync('pnpm', ['audit', '--json', ...args], { | |
| cwd, | |
| encoding: 'utf8', | |
| maxBuffer: 10 * 1024 * 1024, | |
| stdio: ['ignore', 'pipe', 'pipe'], | |
| }); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/pnpm-audit.mjs` around lines 9 - 13, The spawnSync call for the pnpm
audit command in the audit function does not specify an explicit maxBuffer
option, which defaults to 1 MB and can be exceeded by large audit payloads,
causing stdout truncation and JSON.parse failures. Add a maxBuffer property to
the options object passed to spawnSync with a significantly larger value (such
as 10 MB or higher) to accommodate large audit output without truncation.
| "@vue/test-utils": "2.4.6", | ||
| "@vue/tsconfig": "0.8.1", | ||
| "ajv": "8.17.1", | ||
| "ajv": "8.20.0", |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo -e "package\tpeerAjv\tdepAjv\tdevAjv"
jq -r '
.name as $name
| [
$name,
(.peerDependencies.ajv // "none"),
(.dependencies.ajv // "none"),
(.devDependencies.ajv // "none")
]
| `@tsv`
' unraid-ui/package.json web/package.jsonRepository: unraid/api
Length of output: 143
Align ajv peer dependency with the upgraded dev/consumer version.
Line 89 upgrades devDependencies.ajv to 8.20.0, but peerDependencies.ajv remains pinned to 8.17.1. The web/package.json package consumes ajv@8.20.0, creating a peer contract mismatch across workspaces.
Proposed fix
"peerDependencies": {
- "ajv": "8.17.1",
+ "ajv": "8.20.0",
"tailwindcss": "4.1.12",
"vue": "3.5.20"
},🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@unraid-ui/package.json` at line 89, The devDependencies for ajv has been
upgraded to 8.20.0, but the peerDependencies.ajv is still pinned to 8.17.1,
creating a version mismatch. Update the peerDependencies.ajv version from 8.17.1
to 8.20.0 to align with the upgraded devDependencies version and match what is
being consumed in web/package.json.
58b6f3b to
a421619
Compare
|
🚀 Storybook has been deployed to staging: https://unraid-ui-storybook-staging.unraid-workers.workers.dev |
a421619 to
0baec05
Compare
|
🚀 Storybook has been deployed to staging: https://unraid-ui-storybook-staging.unraid-workers.workers.dev |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2028 +/- ##
==========================================
+ Coverage 52.63% 52.64% +0.01%
==========================================
Files 1035 1035
Lines 72034 72038 +4
Branches 8248 8253 +5
==========================================
+ Hits 37917 37927 +10
+ Misses 33991 33985 -6
Partials 126 126 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This plugin has been deployed to Cloudflare R2 and is available for testing. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0baec05c03
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| updateVulnerabilityMetadata(report); | ||
|
|
||
| process.stdout.write(`${JSON.stringify(report, null, 2)}\n`); | ||
| process.exitCode = Object.keys(report.advisories ?? {}).length === 0 ? 0 : (audit.status ?? 1); |
There was a problem hiding this comment.
Preserve audit failures for registry errors
When pnpm audit --json returns a JSON error object instead of an advisory list, this line treats the missing advisories object as empty and exits 0. I reproduced this with the current registry 403 response: node scripts/pnpm-audit.mjs printed ERR_PNPM_AUDIT_BAD_RESPONSE but returned success; pnpm audit --help documents --ignore-registry-errors as the option that should make registry errors exit 0, so without that flag CI will now pass even though the audit did not complete.
Useful? React with 👍 / 👎.
Summary
pnpm-lock.yaml.ipandlodash-es.Validation
pnpm run --silent audit --prodpnpm --filter ./api type-checkpnpm --filter ./api testNotes
ipadvisory is ignored through repo audit policy because npm reports no patched version.pnpm audit --prodstill leaves a stale action for that ignored advisory; use the repo audit script for CI/user checks.Summary by CodeRabbit
Chores
Tests