enhanced error logging#117
Merged
naman-contentstack merged 7 commits intodevelopmentfrom Aug 25, 2025
Merged
Conversation
aman19K
reviewed
Aug 12, 2025
aman19K
reviewed
Aug 12, 2025
aman19K
reviewed
Aug 12, 2025
aman19K
previously approved these changes
Aug 12, 2025
cs-raj
approved these changes
Aug 25, 2025
harshithad0703
approved these changes
Aug 25, 2025
aman19K
reviewed
Aug 25, 2025
Comment on lines
+622
to
+637
| contentTypeErrors.forEach((error, index) => { | ||
| errorDetails += `${index + 1}. UID: "${error.uid}"\n`; | ||
| errorDetails += ` Reason: ${NUMERIC_IDENTIFIER_EXCLUSION_REASON}\n`; | ||
| errorDetails += ` Suggestion: Since UIDs cannot be changed, use the --prefix flag to add a valid prefix to all interface names (e.g., --prefix "ContentType")\n\n`; | ||
| }); | ||
| } | ||
|
|
||
| if (globalFieldErrors.length > 0) { | ||
| errorDetails += "Global Fields Referencing Invalid Content Types:\n\n"; | ||
|
|
||
| globalFieldErrors.forEach((error, index) => { | ||
| errorDetails += `${index + 1}. Global Field: "${error.uid}"\n`; | ||
| errorDetails += ` References: "${error.referenceTo || "Unknown"}"\n`; | ||
| errorDetails += ` Reason: ${NUMERIC_IDENTIFIER_EXCLUSION_REASON}\n`; | ||
| errorDetails += ` Suggestion: Since UIDs cannot be changed, use the --prefix flag to add a valid prefix to all interface names (e.g., --prefix "ContentType")\n\n`; | ||
| }); |
Contributor
There was a problem hiding this comment.
@naman-contentstack , The code inside both loops is quite similar and repetitive. It would be better to move the common logic into a shared function like formatErrorDetails to improve readability and reduce duplication.
aman19K
reviewed
Aug 25, 2025
Comment on lines
+604
to
+650
| if (numericIdentifierErrors.length > 0) { | ||
| // Group errors by type for better organization | ||
| const contentTypeErrors = numericIdentifierErrors.filter( | ||
| (err) => err.type === "content_type" | ||
| ); | ||
| const globalFieldErrors = numericIdentifierErrors.filter( | ||
| (err) => err.type === "global_field" | ||
| ); | ||
|
|
||
| // Build the detailed error message | ||
| let errorDetails = ""; | ||
| errorDetails += `Type generation failed: Found ${numericIdentifierErrors.length} items with numeric identifiers that create invalid TypeScript interface names. Please use the --prefix flag to resolve this issue.\n\n`; | ||
|
|
||
| if (contentTypeErrors.length > 0) { | ||
| errorDetails += "Content Types & Global Fields with Numeric UIDs:\n"; | ||
| errorDetails += | ||
| "Note: Global Fields are Content Types, so they appear in this section if their own UID starts with a number.\n\n"; | ||
|
|
||
| contentTypeErrors.forEach((error, index) => { | ||
| errorDetails += `${index + 1}. UID: "${error.uid}"\n`; | ||
| errorDetails += ` Reason: ${NUMERIC_IDENTIFIER_EXCLUSION_REASON}\n`; | ||
| errorDetails += ` Suggestion: Since UIDs cannot be changed, use the --prefix flag to add a valid prefix to all interface names (e.g., --prefix "ContentType")\n\n`; | ||
| }); | ||
| } | ||
|
|
||
| if (globalFieldErrors.length > 0) { | ||
| errorDetails += "Global Fields Referencing Invalid Content Types:\n\n"; | ||
|
|
||
| globalFieldErrors.forEach((error, index) => { | ||
| errorDetails += `${index + 1}. Global Field: "${error.uid}"\n`; | ||
| errorDetails += ` References: "${error.referenceTo || "Unknown"}"\n`; | ||
| errorDetails += ` Reason: ${NUMERIC_IDENTIFIER_EXCLUSION_REASON}\n`; | ||
| errorDetails += ` Suggestion: Since UIDs cannot be changed, use the --prefix flag to add a valid prefix to all interface names (e.g., --prefix "ContentType")\n\n`; | ||
| }); | ||
| } | ||
|
|
||
| errorDetails += "To resolve these issues:\n"; | ||
| errorDetails += | ||
| " • Use the --prefix flag to add a valid prefix to all interface names\n"; | ||
| errorDetails += " • Example: --prefix 'ContentType'\n"; | ||
|
|
||
| // Throw a comprehensive error with all the details | ||
| throw { | ||
| type: "validation", | ||
| error_code: "VALIDATION_ERROR", | ||
| error_message: errorDetails, | ||
| }; |
Contributor
There was a problem hiding this comment.
@naman-contentstack , Break this logic into multiple methods and organize them within a parent method. Then, call the parent method here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.