From 905289e809bd5675096e596f38d53e1743ad8b9a Mon Sep 17 00:00:00 2001 From: Nate Tovo Date: Wed, 31 Jul 2024 06:31:01 -0500 Subject: [PATCH] fix: allow file config to override `true` default values (#4119) --- lib/config/schema.js | 2 +- test/start/file/elastic-apm-node.js | 3 ++- test/start/file/test.test.js | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/config/schema.js b/lib/config/schema.js index a8f10c8116..1433c53046 100644 --- a/lib/config/schema.js +++ b/lib/config/schema.js @@ -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'; } diff --git a/test/start/file/elastic-apm-node.js b/test/start/file/elastic-apm-node.js index 0ca7eeb99c..a3ceb5e2bc 100644 --- a/test/start/file/elastic-apm-node.js +++ b/test/start/file/elastic-apm-node.js @@ -7,5 +7,6 @@ 'use strict' module.exports = { - serviceName: 'from-file' + serviceName: 'from-file', + active: false } diff --git a/test/start/file/test.test.js b/test/start/file/test.test.js index 925299ff12..0c2deed6bf 100644 --- a/test/start/file/test.test.js +++ b/test/start/file/test.test.js @@ -17,7 +17,17 @@ var agent = require('../../..').start({ const tape = require('tape'); -tape('from-file serviceName test', function (t) { - t.equals(agent._conf.serviceName, 'from-file'); +tape('from-file configuration test', function (t) { + t.equals( + agent._conf.serviceName, + 'from-file', + 'serviceName comes from config file', + ); + t.equals( + agent._conf.active, + false, + 'false values from config file override defaults', + ); + t.equals(agent._conf.captureBody, 'off', 'existing defaults are preserved'); t.end(); });