Skip to content
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

Updating the error message during conditional reference #4691

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Microsoft.Health.Fhir.Core/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/Microsoft.Health.Fhir.Core/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@
<value>Given conditional reference '{0}' does not resolve to a resource.</value>
<comment>{0} is the conditional reference parameter.</comment>
</data>
<data name="InvalidConditionalReferenceToMultipleResources" xml:space="preserve">
<value>Given conditional reference '{0}' resolved to multiple resources.</value>
<comment>{0} is the conditional reference parameter.</comment>
</data>
<data name="InvalidConditionalReferenceParameters" xml:space="preserve">
<value>Resource type and query parameter must be present in a given request '{0}'.</value>
<comment>{0} is the request url.</comment>
Expand Down Expand Up @@ -744,4 +748,4 @@
<value>The FHIR Server ran out of memory while processing an export job. Please use the _maxCount parameter when requesting an export job to reduce the number of resources exported at one time. The count used in this job was {0}</value>
<comment>'{0}' the value of _maxCount used for this export job.</comment>
</data>
</root>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ public async Task ResolveReferencesAsync(Resource resource, IDictionary<string,

var results = await GetExistingResourceId(requestUrl, resourceType, conditionalQueries, cancellationToken);

if (results == null || results.Count != 1)
if (results == null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to be safe, can you add results.Count == 0 to this if statement.

Copy link
Author

Choose a reason for hiding this comment

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

@LTA-Thinking Updated the if statement. Please review it.

{
throw new RequestNotValidException(string.Format(Core.Resources.InvalidConditionalReference, reference.Reference));
}
else if (results.Count != 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

And could you change this check to be if the count is greater than 1.

Copy link
Member

@brendankowitz brendankowitz Oct 22, 2024

Choose a reason for hiding this comment

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

For conditional, we want exactly 1, my only other thought here was 0 (if thats possible), which would still give the wrong error message

Copy link
Author

Choose a reason for hiding this comment

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

@LTA-Thinking , @brendankowitz Updated the if else statement which cover both count = 0 and count >1 condition.

{
throw new RequestNotValidException(string.Format(Core.Resources.InvalidConditionalReferenceToMultipleResources, reference.Reference));
}

string resourceId = results.First().Resource.ResourceId;

Expand Down
Loading