-
Notifications
You must be signed in to change notification settings - Fork 574
Remove pre-emptive constraint validation in import merge operations #5215
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
Draft
Copilot
wants to merge
6
commits into
personal/v-shahamad/Fix_for_Import_to_return_proper_message_in_400_2
Choose a base branch
from
copilot/optimize-merge-checks
base: personal/v-shahamad/Fix_for_Import_to_return_proper_message_in_400_2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
841e878
Initial plan
Copilot 9bbda37
Remove pre-emptive constraint validation and handle SQL errors on fai…
Copilot 98584ee
Add unit test for constraint violation handling
Copilot d8f1621
Clean up Regex usage to use shorter form
Copilot d53e8db
Remove unused ValidateConstraintViolations method to eliminate code d…
Copilot 44fc1bc
Address code review feedback: improve regex consistency and XML docum…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,6 +90,16 @@ public async Task<ImportProcessingProgress> Import(Channel<ImportResource> input | |
| var validResources = resources.Where(r => string.IsNullOrEmpty(r.ImportError)).ToList(); | ||
| var newErrors = await _store.ImportResourcesAsync(validResources, importMode, allowNegativeVersions, eventualConsistency, cancellationToken); | ||
| errors.AddRange(newErrors); | ||
|
|
||
| // Abort import on first constraint violation to avoid wasting compute resources | ||
| // Constraint violations are identified by checking if the error message contains constraint-related keywords | ||
| if (newErrors.Any(e => e.Contains("constraint violation", StringComparison.OrdinalIgnoreCase) || | ||
| e.Contains("Database constraint", StringComparison.OrdinalIgnoreCase))) | ||
| { | ||
| _logger.LogWarning("Constraint violation detected during import. Aborting further processing to conserve resources."); | ||
| throw new InvalidOperationException("Import aborted due to constraint violation. See error logs for details."); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not clear how invalid operation can translate to bad request |
||
| } | ||
|
|
||
| var totalBytes = resources.Sum(_ => (long)_.Length); | ||
| resources.Clear(); | ||
| return (validResources.Count - newErrors.Count, totalBytes); | ||
|
|
||
Oops, something went wrong.
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.
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.
Maybe it is valid, but what is missing is E2E test.