-
Notifications
You must be signed in to change notification settings - Fork 61
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
fix(api): more logs for documents #16606
Conversation
WalkthroughThe changes in this pull request involve enhancements to logging and error handling across multiple components related to document management. The Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (2)
libs/api/domains/documents/src/lib/documentV2.resolver.ts (2)
85-86
: Consider sanitizing error details before logging.
Good addition of document category to error context. However, consider sanitizing the error object before logging to prevent potential exposure of sensitive information.
- error: e,
+ error: {
+ name: e.name,
+ message: e.message,
+ code: e.code
+ },
120-124
: Add error handling for document confirmation.
Good addition of logging for document confirmation actions. However, consider:
- Moving the logging after the confirmation is successful
- Adding error handling with appropriate error logging
@Query(() => DocumentConfirmActions, {
nullable: true,
name: 'documentV2ConfirmActions',
})
async confirmActions(
@Args('input') input: DocumentConfirmActionsInput,
@CurrentUser() user: User,
) {
- this.auditService.audit({
- auth: user,
- namespace: '@island.is/api/document-v2',
- action: 'confirmModal',
- resources: input.id,
- meta: { confirmed: input.confirmed },
- })
- this.logger.info('confirming document modal', {
- category: LOG_CATEGORY,
- id: input.id,
- confirmed: input.confirmed,
- })
- return { id: input.id, confirmed: input.confirmed }
+ try {
+ await this.auditService.audit({
+ auth: user,
+ namespace: '@island.is/api/document-v2',
+ action: 'confirmModal',
+ resources: input.id,
+ meta: { confirmed: input.confirmed },
+ })
+
+ const result = { id: input.id, confirmed: input.confirmed };
+
+ this.logger.info('document modal confirmed successfully', {
+ category: LOG_CATEGORY,
+ id: input.id,
+ confirmed: input.confirmed,
+ })
+
+ return result;
+ } catch (e) {
+ this.logger.error('failed to confirm document modal', {
+ category: LOG_CATEGORY,
+ id: input.id,
+ error: {
+ name: e.name,
+ message: e.message,
+ code: e.code
+ },
+ })
+ throw e;
+ }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (3)
- libs/api/domains/documents/src/lib/documentV2.resolver.ts (2 hunks)
- libs/api/domains/documents/src/lib/models/v2/document.input.ts (1 hunks)
- libs/service-portal/documents/src/components/DocumentLine/DocumentLineV3.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
libs/api/domains/documents/src/lib/documentV2.resolver.ts (1)
Pattern libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
libs/api/domains/documents/src/lib/models/v2/document.input.ts (1)
Pattern libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
libs/service-portal/documents/src/components/DocumentLine/DocumentLineV3.tsx (1)
Pattern libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
🔇 Additional comments (3)
libs/api/domains/documents/src/lib/models/v2/document.input.ts (1)
15-19
: LGTM! The category field implementation looks good.
The implementation follows best practices with proper decorators for GraphQL and validation, maintaining consistency with other optional fields.
libs/api/domains/documents/src/lib/documentV2.resolver.ts (1)
Line range hint 1-224
: Implementation follows coding guidelines.
The resolver implementation adheres to the coding guidelines for libs:
- Uses TypeScript effectively with proper type definitions
- Exports reusable GraphQL resolver
- Maintains consistent error handling patterns
libs/service-portal/documents/src/components/DocumentLine/DocumentLineV3.tsx (1)
85-85
: LGTM!
The addition of categoriesAvailable
to the destructured context enhances the component's ability to access available categories.
libs/service-portal/documents/src/components/DocumentLine/DocumentLineV3.tsx
Show resolved
Hide resolved
Datadog ReportAll test runs ✅ 5 Total Test Services: 0 Failed, 5 Passed Test Services
🔻 Code Coverage Decreases vs Default Branch (1)
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #16606 +/- ##
=======================================
Coverage 36.77% 36.77%
=======================================
Files 6858 6858
Lines 142419 142419
Branches 40620 40620
=======================================
Hits 52378 52378
Misses 90041 90041
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
|
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Api - Documents
What
More detailed logs for subpoena documents
Why
Safety 🚓 👮🏼 🚨
Checklist:
Summary by CodeRabbit
New Features
category
field in document input for enhanced categorization.DocumentLineV3
component to manage document categories and improve error handling for document retrieval.Improvements