Skip to content

refactor: CLI error handling and updates how authentication metadata is captured in import/export commands #2003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 18, 2025

Conversation

aman19K
Copy link
Contributor

@aman19K aman19K commented Jul 17, 2025

This PR refactors the CLI error handling and updates how authentication metadata is captured in import/export commands.

Introduces new helper methods (extractClearMessage, streamlined normalization/classification, enhanced metadata extraction) in CLIErrorHandler.
Standardizes authMethod values, makes it optional in config types, and updates context creation in import/export commands.
Renames context identifiers (userId → userUid, organization_uid → oauthOrgUid) and adjusts BaseCommand.

@aman19K aman19K requested a review from a team as a code owner July 17, 2025 10:24
@aman19K aman19K requested review from Copilot and removed request for a team July 17, 2025 10:24
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the CLI error handling and updates how authentication metadata is captured in import/export commands.

  • Introduces new helper methods (extractClearMessage, streamlined normalization/classification, enhanced metadata extraction) in CLIErrorHandler.
  • Standardizes authMethod values, makes it optional in config types, and updates context creation in import/export commands.
  • Renames context identifiers (userIduserUid, organization_uidoauthOrgUid) and adjusts BaseCommand.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/contentstack-utilities/src/logger/cli-error-handler.ts Refactored error handler: added extractClearMessage, improved metadata and normalization logic
packages/contentstack-import/src/utils/import-config-handler.ts Standardized authMethod strings
packages/contentstack-import/src/types/import-config.ts Made authMethod optional
packages/contentstack-import/src/commands/cm/stacks/import.ts Updated createImportContext to include authMethod and renamed IDs
packages/contentstack-export/src/utils/export-config-handler.ts Standardized authMethod strings
packages/contentstack-export/src/types/export-config.ts Made authMethod optional
packages/contentstack-export/src/commands/cm/stacks/export.ts Updated createExportContext to include authMethod and renamed IDs
packages/contentstack-auth/src/base-command.ts Renamed context IDs
Comments suppressed due to low confidence (3)

packages/contentstack-utilities/src/logger/cli-error-handler.ts:86

  • This new helper method contains several conditional branches; consider adding unit tests for extractClearMessage to verify message formatting for API, network, and generic errors.
  private extractClearMessage(error: Error & Record<string, any>): string {

packages/contentstack-utilities/src/logger/cli-error-handler.ts:83

  • [nitpick] The JSDoc for extractClearMessage only has a summary. It would be helpful to add @param error and @returns tags to clarify expected input and output.
  /**

packages/contentstack-utilities/src/logger/cli-error-handler.ts:222

  • [nitpick] The new metadata extractor no longer includes apiKey from the context. If retaining apiKey in error metadata is important for debugging, consider re-adding it or documenting its removal.
  private extractMeta(context?: ErrorContext, errorType?: string): Record<string, string | undefined> {

@aman19K aman19K changed the title refactor: cli error handler refactor: CLI error handling and updates how authentication metadata is captured in import/export commands Jul 17, 2025
Copy link
Contributor

@sunil-lakshman sunil-lakshman left a comment

Choose a reason for hiding this comment

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

LGTM

@aman19K aman19K merged commit 4683665 into feat/DX-2951-v2Logger-integration Jul 18, 2025
8 checks passed
@aman19K aman19K deleted the feat/DX-3151 branch July 18, 2025 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants