Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/DBSQLClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
* const session = client.connect({host, path, token});
*/
public async connect(options: ConnectionOptions, authProvider?: IAuthentication): Promise<IDBSQLClient> {
const deprecatedClientId = (options as any).clientId;
if (deprecatedClientId !== undefined) {
this.logger.log(
LogLevel.warn,
'Warning: The "clientId" option is deprecated. Please use "userAgentEntry" instead.',
);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

can we assign it to userAgentEntry if it only give the warning.

Copy link
Contributor Author

@shivam2680 shivam2680 Feb 21, 2025

Choose a reason for hiding this comment

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

We can,
but the issue of sensitive info being passed through this param will persist.

Copy link
Collaborator

@jackyhu-db jackyhu-db Feb 21, 2025

Choose a reason for hiding this comment

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

can you try to redact it if it is service principal client id

this.authProvider = this.createAuthProvider(options, authProvider);

this.connectionProvider = this.createConnectionProvider(options);
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/DBSQLClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,25 @@ describe('DBSQLClient.connect', () => {

expect(thriftConnectionStub.on.called).to.be.true;
});

it('should log a warning when deprecated clientId is passed', async () => {
const client = new DBSQLClient();
const logSpy = sinon.spy((client as any).logger, 'log');

const optionsWithDeprecated = {
...connectOptions,
clientId: 'clientId',
};

await client.connect(optionsWithDeprecated as any);

const warningRegex = /Warning: The "clientId" option is deprecated\. Please use "userAgentEntry" instead\./;
const callFound = logSpy.getCalls().some((call) => warningRegex.test(call.args[1]));

expect(callFound).to.be.true;

logSpy.restore();
});
});

describe('DBSQLClient.openSession', () => {
Expand Down
Loading