-
Notifications
You must be signed in to change notification settings - Fork 536
Fixing bulk-delete on custom search parameters. #5026
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
base: main
Are you sure you want to change the base?
Conversation
...ft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/BulkDeleteProcessingJobTests.cs
Fixed
Show fixed
Hide fixed
test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/BulkDeleteTests.cs
Fixed
Show resolved
Hide resolved
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Delete/DeletionService.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Delete/DeletionService.cs
Fixed
Show resolved
Hide resolved
src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Delete/DeletionService.cs
Show resolved
Hide resolved
test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/BulkDeleteTests.cs
Fixed
Show resolved
Hide resolved
test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/BulkDeleteTests.cs
Fixed
Show resolved
Hide resolved
src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Delete/DeletionService.cs
Outdated
Show resolved
Hide resolved
{ | ||
searchParameterStatusList.Add(new ResourceSearchParameterStatus | ||
_logger.LogError(ex, "The search parameter '{Uri}' not supported.", uri); |
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.
Could you add a comment for what could cause this exception and why we want to sometimes ignore it? I think it will be good to have the record of why this was added.
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.
Added the comment (Please review and let me know if it needs to be corrected.)
SearchParameterInfo typeLookup = null; | ||
if (_searchParameterDefinitionManager.TryGetSearchParameter(searchParameter.Uri.OriginalString, out urlLookup)) | ||
{ | ||
_searchParameterDefinitionManager.TryGetSearchParameter(urlLookup.BaseResourceTypes[0], urlLookup.Code, false, out typeLookup); |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null Warning
urlLookup
this
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 days ago
To fix the issue, we need to ensure that urlLookup
is not null
before dereferencing it on line 256. This can be achieved by adding a null check for urlLookup
before accessing its BaseResourceTypes
property. If urlLookup
is null
, the code should skip the operation or handle the case appropriately.
The fix involves:
- Adding a null check for
urlLookup
before line 256. - Ensuring that the logic gracefully handles the case where
urlLookup
isnull
.
-
Copy modified lines R256-R259
@@ -255,3 +255,6 @@ | ||
{ | ||
_searchParameterDefinitionManager.TryGetSearchParameter(urlLookup.BaseResourceTypes[0], urlLookup.Code, false, out typeLookup); | ||
if (urlLookup != null) | ||
{ | ||
_searchParameterDefinitionManager.TryGetSearchParameter(urlLookup.BaseResourceTypes[0], urlLookup.Code, false, out typeLookup); | ||
} | ||
} |
SearchParameterInfo typeLookup = null; | ||
if (_searchParameterDefinitionManager.TryGetSearchParameter(searchParameter.Uri.OriginalString, out urlLookup)) | ||
{ | ||
_searchParameterDefinitionManager.TryGetSearchParameter(urlLookup.BaseResourceTypes[0], urlLookup.Code, false, out typeLookup); |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null Warning
urlLookup
this
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 days ago
To fix the issue, we need to ensure that urlLookup
is not null
before dereferencing it on line 315. This can be achieved by adding a null check for urlLookup
before accessing its BaseResourceTypes
property. If urlLookup
is null
, the code should skip the operation or handle it appropriately.
The fix involves:
- Adding a null check for
urlLookup
before line 315. - Ensuring that the logic gracefully handles the case where
urlLookup
isnull
.
-
Copy modified lines R315-R318
@@ -314,3 +314,6 @@ | ||
{ | ||
_searchParameterDefinitionManager.TryGetSearchParameter(urlLookup.BaseResourceTypes[0], urlLookup.Code, false, out typeLookup); | ||
if (urlLookup != null && urlLookup.BaseResourceTypes.Count > 0) | ||
{ | ||
_searchParameterDefinitionManager.TryGetSearchParameter(urlLookup.BaseResourceTypes[0], urlLookup.Code, false, out typeLookup); | ||
} | ||
} |
Description
The PR will address an issue of the search parameter status going out of sync after $bulk-delete removes search parameter resources.
Related issues
Addresses [issue #121676].
Bug 121676: Hard delete custom search parameter not cleaning up all the data
Testing
Tested manually and also through adding E2E test.
FHIR Team Checklist
Semver Change (docs)
Patch|Skip|Feature|Breaking (reason)