Skip to content

refactor(collector): refcatored config module#2457

Merged
aryamohanan merged 8 commits intofix-config-precedencefrom
test-collector-config-refact
Apr 8, 2026
Merged

refactor(collector): refcatored config module#2457
aryamohanan merged 8 commits intofix-config-precedencefrom
test-collector-config-refact

Conversation

@aryamohanan
Copy link
Copy Markdown
Contributor

@aryamohanan aryamohanan commented Apr 1, 2026

#2448 this needs to merge first

Normalize the collector config. No logic changes only refactored the code.

image

@aryamohanan aryamohanan force-pushed the test-collector-config-refact branch from 5d4d5b9 to 0894a10 Compare April 1, 2026 08:15
@aryamohanan aryamohanan changed the title Test collector config refact refactor(collector): refcatored config module Apr 1, 2026
@aryamohanan aryamohanan force-pushed the test-collector-config-refact branch from 9743148 to ce2c3f7 Compare April 8, 2026 04:04
@aryamohanan aryamohanan marked this pull request as ready for review April 8, 2026 09:23
@aryamohanan aryamohanan requested a review from a team as a code owner April 8, 2026 09:23
@kirrg001
Copy link
Copy Markdown
Contributor

kirrg001 commented Apr 8, 2026

/review

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

🤖 I've received your review request, and I'm working on it now! You can track my progress in the logs for more details.

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Cost: $0.07

* @param {import('@instana/core/src/config').InstanaConfig} config
*/
exports.init = function init(config) {
logger = config.logger;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤔

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 });
};

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 8, 2026

@aryamohanan aryamohanan merged commit 26e3105 into fix-config-precedence Apr 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants