Skip to content

Commit b9a2358

Browse files
committed
Refactor error messages for API key validation in import/export configuration handlers
1 parent daf1307 commit b9a2358

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

packages/contentstack-export/src/utils/export-config-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const setupConfig = async (exportCmdFlags: any): Promise<ExportConfig> => {
8383
exportCmdFlags['stack-uid'] || exportCmdFlags['stack-api-key'] || config.source_stack || (await askAPIKey());
8484
if (typeof config.apiKey !== 'string' || !config.apiKey || !config.apiKey.trim()) {
8585
log.debug('Invalid or empty API key received!', { apiKey: config.apiKey });
86-
throw new Error('Stack API key cannot be empty. Please provide a valid stack API key.');
86+
throw new Error('Invalid or empty API key received. Please provide a valid stack API key.');
8787
}
8888
}
8989
}

packages/contentstack-export/test/unit/utils/export-config-handler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ describe('Export Config Handler', () => {
339339
await setupConfig(flags);
340340
expect.fail('Should have thrown an error');
341341
} catch (error: any) {
342-
expect(error.message).to.include('Invalid API key received');
342+
expect(error.message).to.include('Invalid or empty API key received. Please provide a valid stack API key.');
343343
}
344344
});
345345
});

packages/contentstack-import-setup/src/utils/import-config-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const setupConfig = async (importCmdFlags: any): Promise<ImportConfig> => {
6161
config.apiKey =
6262
importCmdFlags['stack-uid'] || importCmdFlags['stack-api-key'] || config.target_stack || (await askAPIKey());
6363
if (typeof config.apiKey !== 'string' || !config.apiKey || !config.apiKey.trim()) {
64-
throw new Error('Stack API key cannot be empty. Please provide a valid stack API key.');
64+
throw new Error('Invalid or empty API key received. Please provide a valid stack API key.');
6565
}
6666
}
6767
}

packages/contentstack-import/src/utils/import-config-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const setupConfig = async (importCmdFlags: any): Promise<ImportConfig> => {
8383
importCmdFlags['stack-uid'] || importCmdFlags['stack-api-key'] || config.target_stack || (await askAPIKey());
8484
if (typeof config.apiKey !== 'string' || !config.apiKey || !config.apiKey.trim()) {
8585
log.debug('Invalid or empty API key received!', { apiKey: config.apiKey });
86-
throw new Error('Stack API key cannot be empty. Please provide a valid stack API key.');
86+
throw new Error('Invalid or empty API key received. Please provide a valid stack API key.');
8787
}
8888
}
8989
}

0 commit comments

Comments
 (0)