File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,6 +102,12 @@ describe('configuration', () => {
102102 await expect ( async ( ) => act ( ) ) . rejects . toThrow ( / m u s t n o t c o n t a i n a n e m p t y a c c o u n t i d / ) ;
103103 } ) ;
104104
105+ it ( 'refuses an empty accountId rather than widening to every account' , ( ) => {
106+ expect ( ( ) => newToolSet ( { accountId : '' } ) ) . toThrow (
107+ new ToolSetConfigError ( 'accountId must not be an empty string' ) ,
108+ ) ;
109+ } ) ;
110+
105111 it ( 'returns itself from setAccounts for chaining' , ( ) => {
106112 const toolset = newToolSet ( ) ;
107113 expect ( toolset . setAccounts ( [ 'acc1' ] ) ) . toBe ( toolset ) ;
Original file line number Diff line number Diff line change @@ -325,14 +325,19 @@ export class StackOneToolSet {
325325
326326 /**
327327 * @throws ToolSetConfigError If no API key is given or found in `STACKONE_API_KEY`, or both
328- * `accountId` and `accountIds` are given.
328+ * `accountId` and `accountIds` are given, or `accountId` is an empty string .
329329 */
330330 constructor ( config : StackOneToolSetConfig = { } ) {
331331 if ( config . accountId != null && config . accountIds != null ) {
332332 throw new ToolSetConfigError (
333333 'Cannot provide both accountId and accountIds. Use accountId for a single account or accountIds for multiple accounts.' ,
334334 ) ;
335335 }
336+ // An empty accountId is usually an unset variable, and treating it as unset would silently
337+ // widen every call to all active accounts.
338+ if ( config . accountId === '' ) {
339+ throw new ToolSetConfigError ( 'accountId must not be an empty string' ) ;
340+ }
336341 assertAccountIdList ( config . accountIds , 'accountIds' ) ;
337342 assertAccountIdList ( config . execute ?. accountIds , 'execute.accountIds' ) ;
338343
You can’t perform that action at this time.
0 commit comments