-
-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summary
Comprehensive code review identified 67 additional issues beyond the 12 already documented in issue 71. This issue tracks all findings for resolution before adding new features.
Critical Issues
Issue 1. Copy-Paste Bug in CertificateStoreCredentialProvider ✅
Location: src/PPDS.Auth/Credentials/CertificateStoreCredentialProvider.cs:228
Uses StoreName= instead of StoreLocation= for the store location parameter. Will cause authentication failures for non-default certificate stores.
Fix: Change to StoreLocation={_storeLocation}. FIXED (pending commit)
Issue 2. Memory Leak in DeviceCodeCredentialProvider.Dispose() ✅
Location: src/PPDS.Auth/Credentials/DeviceCodeCredentialProvider.cs:260-266
Dispose() does not dispose _cacheHelper or unregister token cache. File locks persist after disposal.
Fix: Add cache unregistration and disposal in Dispose method. FIXED (pending commit)
Issue 3. Memory Leak in UsernamePasswordCredentialProvider.Dispose() ✅
Location: src/PPDS.Auth/Credentials/UsernamePasswordCredentialProvider.cs:162-168
Same issue as Issue 2 - incomplete Dispose().
Fix: Added cache unregistration. FIXED (pending commit)
Issue 4. Double-Checked Locking Bug in ConnectionStringSource ✅
Location: src/PPDS.Dataverse/Pooling/ConnectionStringSource.cs:50-53
_client field is not volatile in double-checked locking pattern. Can cause visibility issues with partially-constructed objects.
Fix: Mark _client as volatile. FIXED (pending commit)
Issue 5. Non-Volatile Counter in ThrottleAwareStrategy ❌ FALSE POSITIVE
Location: src/PPDS.Dataverse/Pooling/Strategies/ThrottleAwareStrategy.cs:15
_counter field used with Interlocked.Increment but not marked volatile.
Analysis: Interlocked.Increment provides full memory barriers. The volatile keyword is NOT required when using Interlocked operations. The code is correct as-is.
High Issues
Issue 6. Thread-Unsafe Static JsonSerializerOptions ❌ FALSE POSITIVE
Locations: Various CLI commands
Analysis: All instances are already static readonly - verified in ListCommand.cs, CleanCommand.cs, ExtractCommand.cs, DeployCommand.cs, DiffCommand.cs.
Issue 7. Thread-Unsafe ConsoleProgressReporter ✅ DOCUMENTED
Location: src/PPDS.Migration/Progress/ConsoleProgressReporter.cs:17-19
Fields mutated without synchronization.
Fix: CLI is single-threaded. Added /// <remarks>This class is not thread-safe.</remarks> doc comment. FIXED (commit 1be65e9)
Issue 8. Mutable Default in ManyToManyRelationshipData ❌ FALSE POSITIVE
Location: src/PPDS.Migration/Models/MigrationData.cs:62-93
Analysis: = new() creates a NEW list per instance. This is NOT a shared mutable default - each instance gets its own independent list.
Issue 9. Incomplete Role Mapping ✅ DOCUMENTED
Location: src/PPDS.Migration/Import/TieredImporter.cs:875-914
Fix: Added XML documentation explaining role mapping limitation. Returns null which is handled gracefully downstream. Proper fix requires schema changes - tracking as future enhancement. FIXED (commit 1be65e9)
Issue 10. Silent Exception in ExtractEnvironmentName ❌ FALSE POSITIVE
Location: src/PPDS.Cli/Commands/Auth/AuthCommandGroup.cs:1288-1307
Analysis: The function returns the original URL as a fallback when parsing fails. This is intentional behavior for a display helper.
Update: Also refactored to use Uri.TryCreate() in issue 71 fixes.
Issue 11. Resource Leak in EnvCommandGroup ❌ FALSE POSITIVE
Location: src/PPDS.Cli/Commands/Env/EnvCommandGroup.cs:354-361
Analysis: The code correctly uses await using for both serviceProvider and client. Resources are properly disposed.
Issue 12. Connection Source Ownership Unclear ❌ FALSE POSITIVE
Location: src/PPDS.Auth/Pooling/ConnectionResolver.cs:19
Analysis: ConnectionResolver.Dispose() (lines 211-224) iterates _sources and disposes each one. Ownership is clear and disposal is implemented.
Medium Issues
Issue 13. SRP Violation - PooledClient
Location: src/PPDS.Dataverse/Pooling/PooledClient.cs:226-330
Mixes pool return semantics with throttle detection.
Status: Low priority refactor - defer to future.
Issue 14. SRP Violation - BulkOperationExecutor
Location: src/PPDS.Dataverse/BulkOperations/BulkOperationExecutor.cs:659-882
224-line method handles 7 different concerns.
Status: Low priority refactor - defer to future.
Issue 15. SRP Violation - Console Output in Auth Library ✅
Locations: InteractiveBrowserCredentialProvider, DeviceCodeCredentialProvider, GlobalDiscoveryService
Fix: Created AuthenticationOutput class replacing 26 Console.WriteLine calls with configurable output. Library consumers can set AuthenticationOutput.Writer = null to suppress or provide custom Action<string>. FIXED (commit 1be65e9)
Issue 16. ISP Violation - ICredentialProvider
Location: src/PPDS.Auth/ICredentialProvider.cs:36-74
Interface exposes properties not applicable to all implementations.
Status: Low priority refactor - defer to future.
Issue 17. Code Duplication - MSAL Initialization ✅
Locations: Multiple credential providers
Fix: Extracted to MsalClientBuilder helper class. FIXED (pending commit)
Issue 18. God Object - TieredImporter
Location: src/PPDS.Migration/Import/TieredImporter.cs:28-1069
1000+ lines handling multiple concerns.
Status: Low priority refactor - defer to future.
Issue 19. Silent Exception Swallowing ✅
Location: src/PPDS.Migration/Import/TieredImporter.cs:905-908
Fix: Added LogDebug. FIXED (pending commit)
Issue 20. Exception Message Not Redacted ✅
Location: src/PPDS.Migration/Import/TieredImporter.cs:524
Fix: Added redaction. FIXED (pending commit)
Issue 21-22. Missing Input Validation ✅
Locations: CmtSchemaReader, ImportOptions
Fix: Added validation. FIXED (pending commit)
Issue 23. Nullable Handling Issues ❌ FALSE POSITIVE
Locations: ErrorOutput.cs, EnvironmentResolverHelper.cs, ProfileServiceFactory.cs
Analysis: All three cases have proper null handling:
ErrorOutput.cs:27- Has null check with ternaryEnvironmentResolverHelper.cs:118- Null-forgiveness after validationProfileServiceFactory.cs:120-uri.Hostcannot be null for http/https URIs
Issue 24. Error Code Lost ✅
Location: src/PPDS.Dataverse/BulkOperations/BulkOperationExecutor.cs:850-869
Fix: Added ExtractErrorCode helper. FIXED (pending commit)
Issue 25. Inconsistent Nullable Assignment ❌ FALSE POSITIVE
Location: src/PPDS.Dataverse/Pooling/PooledClient.cs:199-201
Analysis: ServiceClient.CallerAADObjectId property accepts Guid?, so assigning the nullable directly is correct. Line 196 uses .Value because CallerId expects Guid, not Guid?.
Issue 26. Endpoint Type Duplication ✅
Location: src/PPDS.Auth/Discovery/GlobalDiscoveryService.cs:98-109
Fix: Unified to baseUrl. FIXED (pending commit)
Issue 27. No Defensive Validation ✅
Location: src/PPDS.Auth/CredentialProviderFactory.cs:18-41
Fix: Added ValidateRequiredFields() with descriptive error messages for GitHubFederated, AzureDevOpsFederated, UsernamePassword auth methods. FIXED (commit 1be65e9)
Low Issues
Issues 28-35. Missing/Incomplete XML Documentation
Various locations need documentation improvements.
Status: Low priority - defer to future.
Issues 36-40. Code Duplication
Various duplicated patterns.
Status: Low priority - defer to future.
Issue 41. Dead Code ✅
Location: src/PPDS.Dataverse/BulkOperations/BulkOperationExecutor.cs:1377-1448
ExecuteBatchesParallelAsync never called.
Fix: Removed. FIXED (pending commit)
Issues 42-45. Minor Improvements
- DataverseConnection validates null but not empty string
- Magic numbers in PluginRegistrationService
- ExecutionOrder validation
- JSON deep copy performance
Status: Low priority - defer to future.
Checklist
Critical
- Issue 1 - Fix copy-paste bug in CertificateStoreCredentialProvider (pending commit)
- Issue 2 - Fix memory leak in DeviceCodeCredentialProvider (pending commit)
- Issue 3 - Fix memory leak in UsernamePasswordCredentialProvider (pending commit)
- Issue 4 - Fix double-checked locking in ConnectionStringSource (pending commit)
-
Issue 5 - Non-volatile counterFALSE POSITIVE
High
-
Issue 6 - Static JsonSerializerOptionsFALSE POSITIVE - Issue 7 - Document ConsoleProgressReporter thread safety (commit 1be65e9)
-
Issue 8 - Mutable defaultFALSE POSITIVE - Issue 9 - Document role mapping limitation (commit 1be65e9)
-
Issue 10 - Silent exceptionFALSE POSITIVE (also fixed in issue 71) -
Issue 11 - Resource leakFALSE POSITIVE -
Issue 12 - Connection source ownershipFALSE POSITIVE
Medium
- Issues 13, 14, 16, 18 - SRP/ISP refactors (defer to future)
- Issue 15 - AuthenticationOutput for configurable messaging (commit 1be65e9)
- Issue 17 - Extract MsalClientBuilder (pending commit)
- Issue 19 - Fix silent exception in TieredImporter (pending commit)
- Issue 20 - Add exception redaction (pending commit)
- Issues 21-22 - Add input validation (pending commit)
-
Issue 23 - Nullable handlingFALSE POSITIVE - Issue 24 - Preserve error codes (pending commit)
-
Issue 25 - Nullable assignmentFALSE POSITIVE - Issue 26 - Fix endpoint type duplication (pending commit)
- Issue 27 - Add defensive validation (commit 1be65e9)
Low
- Issues 28-35 - XML documentation (defer to future)
- Issues 36-40 - Code duplication (defer to future)
- Issue 41 - Remove dead code (pending commit)
- Issues 42-45 - Minor improvements (defer to future)
Labels
bug, technical-debt, pre-release
Related
- Issue 71 (original code review findings)
Metadata
Metadata
Assignees
Labels
Projects
Status