Skip to content

[Debug Branch] Log and skip error at object level#98

Open
kchiranjewee63 wants to merge 2 commits intomainfrom
log-and-skip-object-errors
Open

[Debug Branch] Log and skip error at object level#98
kchiranjewee63 wants to merge 2 commits intomainfrom
log-and-skip-object-errors

Conversation

@kchiranjewee63
Copy link
Copy Markdown
Contributor

No description provided.

@kchiranjewee63 kchiranjewee63 requested a review from a team as a code owner September 24, 2025 16:59
Copilot AI review requested due to automatic review settings September 24, 2025 16:59
Copy link
Copy Markdown

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 modifies error handling behavior in the entity object processing logic to log validation errors and skip problematic objects instead of failing the entire operation. The change converts a fail-fast approach to a more resilient processing pattern.

  • Changes error handling from returning early on validation failure to logging and continuing
  • Adds JSON marshaling to capture complete object details in error logs
  • Implements graceful degradation by skipping invalid objects rather than stopping processing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

// Log the complete object and skip it instead of returning error
objectJSON, jsonErr := json.Marshal(object)
if jsonErr != nil {
log.Printf("[ERROR] Failed to marshal object for logging: %v. Original error: %s", jsonErr, adapterErr.Message)
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

The error message format is inconsistent - using %v for jsonError but %s for adapterErr.Message. Both should use %v for consistency since they're both error types.

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +99
objectJSON, jsonErr := json.Marshal(object)
if jsonErr != nil {
log.Printf("[ERROR] Failed to marshal object for logging: %v. Original error: %s", jsonErr, adapterErr.Message)
} else {
log.Printf("[ERROR] Skipping object due to validation error. Entity: %s, Error: %s, Object: %s",
reverseMapping.Id, adapterErr.Message, string(objectJSON))
}
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

Logging the complete object JSON may expose sensitive data in logs. Consider redacting or limiting the logged object content, especially if objects may contain PII or sensitive information.

Suggested change
objectJSON, jsonErr := json.Marshal(object)
if jsonErr != nil {
log.Printf("[ERROR] Failed to marshal object for logging: %v. Original error: %s", jsonErr, adapterErr.Message)
} else {
log.Printf("[ERROR] Skipping object due to validation error. Entity: %s, Error: %s, Object: %s",
reverseMapping.Id, adapterErr.Message, string(objectJSON))
}
// Avoid logging full object to prevent leaking sensitive data
log.Printf("[ERROR] Skipping object due to validation error. Entity: %s, Error: %s, ObjectType: %T",
reverseMapping.Id, adapterErr.Message, object)

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 24, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.59%. Comparing base (a56fa4c) to head (6130f75).

Files with missing lines Patch % Lines
web/json_object.go 0.00% 9 Missing ⚠️
server/internal/response.go 66.66% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #98      +/-   ##
==========================================
- Coverage   48.70%   48.59%   -0.11%     
==========================================
  Files          24       24              
  Lines        2655     2669      +14     
==========================================
+ Hits         1293     1297       +4     
- Misses       1306     1314       +8     
- Partials       56       58       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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