Skip to content

Commit 632b2c5

Browse files
manish-bothraclaude
andcommitted
A11Y-13909: name only the collector host in the split-collector warning
httpsOverride normalizes to origin + pathname, so the path survives and can carry a token. The warning now names the host, which is the part that answers the question it asks - whether the two collectors are the same environment - and a test pins that a path in the value never reaches the log. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 1c70e71 commit 632b2c5

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎bin/helpers/utils.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,10 @@ exports.validateCollectorUrls = () => {
581581
remoteReporterApiUrl();
582582
// Remote-only means this process keeps its built-in collector while the machine reports to
583583
// another one. That is correct when the built-in default has been pointed at the same
584-
// environment, and a silently split build when it has not.
584+
// environment, and a silently split build when it has not. Only the host is named: the
585+
// path survives normalization and can carry a token.
585586
if (process.env[REMOTE_API_URL_ENV] && !process.env[API_URL_ENV]) {
586-
logger.warn(`${REMOTE_API_URL_ENV} is set without ${API_URL_ENV}: this run will create its build on the built-in collector and the remote reporter will post test results to ${remoteReporterApiUrl()}. Both must be the same environment.`);
587+
logger.warn(`${REMOTE_API_URL_ENV} is set without ${API_URL_ENV}: this run will create its build on the built-in collector and the remote reporter will post test results to ${new URL(remoteReporterApiUrl()).host}. Both must be the same environment.`);
587588
}
588589
};
589590

‎test/unit/bin/helpers/utils.js‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,13 +1022,25 @@ describe('utils', () => {
10221022
try {
10231023
utils.validateCollectorUrls();
10241024
sinon.assert.calledOnce(warn);
1025-
expect(warn.firstCall.args[0]).to.match(/https:\/\/collector-public\.bsstag\.com/);
1025+
expect(warn.firstCall.args[0]).to.match(/collector-public\.bsstag\.com/);
10261026
expect(warn.firstCall.args[0]).to.match(/same environment/);
10271027
} finally {
10281028
warn.restore();
10291029
}
10301030
});
10311031

1032+
it('names only the host in that warning, never the path', () => {
1033+
process.env.BROWSERSTACK_TEST_OBSERVABILITY_REMOTE_API_URL = 'https://collector-public.bsstag.com/t0ken';
1034+
const warn = sinon.stub(logger, 'warn');
1035+
1036+
try {
1037+
utils.validateCollectorUrls();
1038+
expect(warn.firstCall.args[0]).to.not.match(/t0ken/);
1039+
} finally {
1040+
warn.restore();
1041+
}
1042+
});
1043+
10321044
it('does not warn when both collector urls are set', () => {
10331045
process.env.BROWSERSTACK_TEST_OBSERVABILITY_API_URL = 'https://collector-private.bsstag.com';
10341046
process.env.BROWSERSTACK_TEST_OBSERVABILITY_REMOTE_API_URL = 'https://collector-public.bsstag.com';

0 commit comments

Comments
 (0)