refactor(collector): refcatored config module#2457
refactor(collector): refcatored config module#2457aryamohanan merged 8 commits intofix-config-precedencefrom
Conversation
5d4d5b9 to
0894a10
Compare
9743148 to
ce2c3f7
Compare
|
/review |
|
🤖 I've received your review request, and I'm working on it now! You can track my progress in the logs for more details. |
| * @param {import('@instana/core/src/config').InstanaConfig} config | ||
| */ | ||
| exports.init = function init(config) { | ||
| logger = config.logger; |
There was a problem hiding this comment.
🟠 High: The init function uses config.logger without validation. If config is null, undefined, or doesn't have a logger property, this will throw a TypeError. Add defensive checks: if (!config || !config.logger) before attempting to access config.logger.
Prompt for Bob
Your task is to check if the following issue is valid. If so, understand the root cause and fix it.
<issue>
🟠 High: The `init` function uses `config.logger` without validation. If `config` is null, undefined, or doesn't have a `logger` property, this will throw a TypeError. Add defensive checks: `if (!config || !config.logger)` before attempting to access `config.logger`.
</issue>
You can find the issue in this file:
<path>
packages/collector/src/util/normalizeConfig.js
</path>
Around this line:
<line>
17
</line>
| * @param {import('@instana/core/src/config').InstanaConfig} config | ||
| */ | ||
| exports.init = function init(config) { | ||
| util.init(config.logger); |
There was a problem hiding this comment.
🤔
This looks wrong to me.
The collector initializes the core already early (packages/collector/src/index.js).
This call belongs to
packages/core/src/config/index.js
module.exports.init = _logger => {
logger = _logger;
configNormalizers.init({ logger });
};
|



#2448 this needs to merge first
Normalize the collector config. No logic changes only refactored the code.