Skip to content

Commit

Permalink
fix: allow file config to override true default values
Browse files Browse the repository at this point in the history
This allows a "false" boolean value to override a "true" default value when loading the options via the elastic-apm-node.js config file

Fixes: elastic#4112
Closes: elastic#4112
  • Loading branch information
csnate committed Jul 2, 2024
1 parent 8472afa commit b04fd1f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/config/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ CONFIG_SCHEMA.forEach((def) => {
if (def.envVar && process.env[def.envVar]) {
def.environmentValue = process.env[def.envVar];
def.source = 'environment';
} else if (fileOpts && fileOpts[def.name]) {
} else if (fileOpts && typeof fileOpts[def.name] !== 'undefined') {
def.fileValue = fileOpts[def.name];
def.source = 'file';
}
Expand Down
3 changes: 2 additions & 1 deletion test/start/file/elastic-apm-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
'use strict'

module.exports = {
serviceName: 'from-file'
serviceName: 'from-file',
active: false
}
2 changes: 2 additions & 0 deletions test/start/file/test.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ const tape = require('tape');

tape('from-file serviceName test', function (t) {
t.equals(agent._conf.serviceName, 'from-file');
t.equals(agent._conf.active, false);
t.equals(agent._conf.captureBody, 'off'); // Existing default
t.end();
});

0 comments on commit b04fd1f

Please sign in to comment.