-
Notifications
You must be signed in to change notification settings - Fork 92
Make node-rdkafka required dependency #9428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Make node-rdkafka required dependency #9428
Conversation
📝 WalkthroughWalkthroughThis PR moves Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 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. Comment |
There was a problem hiding this 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
🤖 Fix all issues with AI agents
In `@package.json`:
- Line 113: Pick and implement one consistent approach: either make node-rdkafka
truly required or keep it optional. If required: change
src/util/notifications_util.js to stop using require_optional() and use a direct
require('node-rdkafka') in the Notification/producer code paths (remove
null-check fallbacks), update any functions referencing require_optional()
accordingly, and update src/deploy/NVA_build/Base.Dockerfile to always install
librdkafka (remove USE_RDKAFKA conditional and outdated comment). If optional:
revert node-rdkafka back to optionalDependencies in package.json (or ensure npm
install uses --save-optional), keep require_optional() usage in
notifications_util.js and its null-safe logic, and keep Dockerfile conditional
logic and comment consistent with optional availability; ensure behavior/tests
still handle the missing module path.
| "morgan": "1.10.1", | ||
| "nan": "2.24.0", | ||
| "node-addon-api": "8.5.0", | ||
| "node-rdkafka": "3.6.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if there are any conditional/try-catch imports of node-rdkafka
rg -n 'node-rdkafka' --type js --type ts -C 3Repository: noobaa/noobaa-core
Length of output: 589
🏁 Script executed:
#!/bin/bash
# Check for Dockerfiles and special handling of optional dependencies
fd -e Dockerfile -e Makefile | head -20Repository: noobaa/noobaa-core
Length of output: 457
🏁 Script executed:
#!/bin/bash
# Check for any try-catch or require patterns around node-rdkafka
rg -n 'require.*node-rdkafka|import.*node-rdkafka' -C 5Repository: noobaa/noobaa-core
Length of output: 1685
🏁 Script executed:
#!/bin/bash
# Look at package.json structure to understand the overall dependency strategy
head -150 package.jsonRepository: noobaa/noobaa-core
Length of output: 5523
🏁 Script executed:
#!/bin/bash
# Check the require_optional implementation to understand how it works
rg -n 'require_optional' -A 10 src/util/js_utils.jsRepository: noobaa/noobaa-core
Length of output: 375
🏁 Script executed:
#!/bin/bash
# Check all usages of require_optional in the codebase
rg -n 'require_optional' --type js --type ts | head -30Repository: noobaa/noobaa-core
Length of output: 369
🏁 Script executed:
#!/bin/bash
# Check the exact Dockerfile context around the USE_RDKAFKA logic
sed -n '15,40p' src/deploy/NVA_build/Base.DockerfileRepository: noobaa/noobaa-core
Length of output: 1158
🏁 Script executed:
#!/bin/bash
# Verify if the PR updated notifications_util.js or any other files related to rdkafka
git diff --name-only HEAD~1 HEAD 2>/dev/null | grep -E '(notifications|rdkafka|Dockerfile)' || echo "Git history not available"Repository: noobaa/noobaa-core
Length of output: 87
node-rdkafka is now required, but code and Dockerfile still treat it as optional — requires coordination.
Moving node-rdkafka from optionalDependencies to dependencies creates a critical architectural mismatch:
- Code (
src/util/notifications_util.js): Imports viarequire_optional(), expecting graceful null if missing - Dockerfile (
src/deploy/NVA_build/Base.Dockerfile): Still has conditional logic (USE_RDKAFKA=1) and outdated comment stating "It was added to optionalDependencies because it's not available on all platforms" - package.json: Now requires
node-rdkafka—npm installwill hard-fail without librdkafka
This inconsistency must be resolved:
- If making rdkafka required, remove
require_optional()and update code to assume it's always available - If keeping optional behavior, revert to
optionalDependenciesor add--save-optionalto the npm install - Update Dockerfile comment and conditional logic accordingly
The PR appears incomplete — it moved the dependency but didn't update consuming code or build logic to match the new requirement level.
🤖 Prompt for AI Agents
In `@package.json` at line 113, Pick and implement one consistent approach: either
make node-rdkafka truly required or keep it optional. If required: change
src/util/notifications_util.js to stop using require_optional() and use a direct
require('node-rdkafka') in the Notification/producer code paths (remove
null-check fallbacks), update any functions referencing require_optional()
accordingly, and update src/deploy/NVA_build/Base.Dockerfile to always install
librdkafka (remove USE_RDKAFKA conditional and outdated comment). If optional:
revert node-rdkafka back to optionalDependencies in package.json (or ensure npm
install uses --save-optional), keep require_optional() usage in
notifications_util.js and its null-safe logic, and keep Dockerfile conditional
logic and comment consistent with optional availability; ensure behavior/tests
still handle the missing module path.
Signed-off-by: Utkarsh Srivastava <[email protected]> update package-lock.json Signed-off-by: Utkarsh Srivastava <[email protected]>
2859353 to
7f9eb75
Compare
|
Moved this to draft as I am trying to get downstream to not skip optional deps at least when building for linux/amd64. If not then would move this out of draft. |
Describe the Problem
Downstream builds ignore
optionalDependencywhich means new downstream noobaa-core images do not contain node-rdkafka.Explain the Changes
This PR makes
node-rdkafkadependency required.Issues: Fixed #xxx / Gap #xxx
Testing Instructions:
Summary by CodeRabbit