Skip to content

Conversation

@joshsmithxrm
Copy link
Owner

Summary

  • Add FormatCleanFaultMessage() helper to extract clean, single-line error message from FaultException
  • Log FaultException errors at Error level with clean message format: {message} (ErrorCode: 0x{code:X8})
  • Full exception details available at Debug level for troubleshooting
  • Fixes the duplicate error messages that appeared 2-3 times due to nested FaultDetail structure in FaultException<OrganizationServiceFault>.ToString()

Before:

System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Territory With Ids = 81b3de06... Do Not Exist (Fault Detail is equal to Exception details: ErrorCode: 0x80040217 Message: Territory With Ids = 81b3de06... Do Not Exist TimeStamp: 2026-01-07T15:44:51Z -- Exception details: ErrorCode: 0x80040217 Message: Territory With Ids = 81b3de06... Do Not Exist TimeStamp: ...

After:

CreateMultiple batch failed. Entity: territory, BatchSize: 10. Territory With Ids = 81b3de06... Does Not Exist (ErrorCode: 0x80040217)

Test plan

  • Unit tests pass (649 tests in PPDS.Dataverse.Tests)
  • Build succeeds with --warnaserror
  • Manual testing with Dataverse errors would confirm clean output

Closes #276

🤖 Generated with Claude Code

FaultException<OrganizationServiceFault> errors were showing the same
message 2-3 times in a single log line due to nested FaultDetail structure.
When LogError(ex, ...) is called, the formatter uses ex.ToString() which
includes the nested FaultDetail with repeated messages.

Changes:
- Add FormatCleanFaultMessage() to extract single clean message with error code
- Log FaultException errors at Error level with clean single-line message
- Full exception details available at Debug level for troubleshooting

Before: "System.ServiceModel.FaultException`1[...]: Territory Does Not Exist
(Fault Detail is equal to Exception details: ErrorCode: 0x80040217 Message:
Territory Does Not Exist TimeStamp: ... -- Exception details: ErrorCode: ..."

After: "CreateMultiple batch failed. Entity: territory, BatchSize: 10.
Territory With Ids = 81b3de06... Does Not Exist (ErrorCode: 0x80040217)"

Closes #276

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copilot AI review requested due to automatic review settings January 10, 2026 06:14
@gemini-code-assist
Copy link

Summary of Changes

Hello @joshsmithxrm, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the clarity and conciseness of error logging for bulk operations by eliminating redundant information from FaultException messages. It refactors the logging mechanism to present a clean, single-line error message at the Error level, which includes the relevant error code, while preserving the complete exception details for debugging purposes at the Debug level. This change improves log readability and streamlines error diagnosis.

Highlights

  • Error Message Duplication Fix: Addresses and resolves the issue of FaultException<OrganizationServiceFault> messages appearing multiple times in bulk operation logs due to nested FaultDetail structures.
  • New Formatting Helper: Introduces a new private static helper method, FormatCleanFaultMessage(), to extract concise, single-line error messages including the error code from FaultException instances.
  • Improved Log Readability: Error-level logs now display a clean format: {message} (ErrorCode: 0x{code:X8}), making logs easier to parse and understand at a glance.
  • Debug-Level Full Details: Full exception details for FaultException are now logged at the Debug level, ensuring comprehensive information is available for in-depth troubleshooting without cluttering standard error logs.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively addresses the issue of duplicated error messages in logs for FaultException<OrganizationServiceFault>. The introduction of the FormatCleanFaultMessage helper and the conditional logging logic is a clean solution. It improves log readability by providing a concise error message at the Error level, while still preserving the full exception details for debugging at the Debug level. The suggestion to use string.IsNullOrEmpty for more robust message formatting remains valid.

Copy link

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 fixes duplicate error messages that appear in bulk operation logs when FaultException<OrganizationServiceFault> errors occur. The duplication stems from the nested FaultDetail structure in FaultException.ToString() which repeats the error message 2-3 times in a single log line.

Changes:

  • Added FormatCleanFaultMessage() helper method to extract and format clean, single-line error messages from FaultException<OrganizationServiceFault>
  • Updated error logging to use clean formatted messages at Error level and full exception details at Debug level for troubleshooting
  • Added comprehensive documentation explaining the rationale for the change

Reviewed changes

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

File Description
src/PPDS.Dataverse/BulkOperations/BulkOperationExecutor.cs Added FormatCleanFaultMessage() helper and updated exception logging logic to provide clean error messages for FaultExceptions while preserving full details at Debug level
.claude/worker-plan.md Added implementation plan documenting the problem, solution approach, and acceptance criteria mapping

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
....Dataverse/BulkOperations/BulkOperationExecutor.cs 81.81% 0 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@joshsmithxrm
Copy link
Owner Author

Please remove .claude/worker-plan.md from this PR - it's a session-specific file that shouldn't be committed.

git rm .claude/worker-plan.md
git commit --amend --no-edit
git push --force-with-lease

PR #324 adds this file to .gitignore to prevent this in the future.

Address Gemini review feedback - use string.IsNullOrEmpty instead
of null-coalescing operator to ensure we fall back to faultEx.Message
if fault.Message is an empty string.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@joshsmithxrm joshsmithxrm merged commit 7b5daa1 into main Jan 10, 2026
13 of 14 checks passed
@joshsmithxrm joshsmithxrm deleted the issue-276 branch January 10, 2026 13:41
@github-project-automation github-project-automation bot moved this from Todo to Done in PPDS Roadmap Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix: clean up error message duplication in logs

2 participants