diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Search/SearchValues/QuantitySearchValueTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Search/SearchValues/QuantitySearchValueTests.cs index c32156364e..40f0161446 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Search/SearchValues/QuantitySearchValueTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Search/SearchValues/QuantitySearchValueTests.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; +using Microsoft.Health.Fhir.Core.Features.Persistence; using Microsoft.Health.Fhir.Core.Features.Search.SearchValues; using Xunit; @@ -66,7 +67,7 @@ public void GivenAnInvalidString_WhenParsing_ThenExceptionShouldBeThrown(string [InlineData(@"abc|system|code")] public void GivenAnInvalidNumber_WhenParsing_ThenExceptionShouldBeThrown(string s) { - Assert.Throws(() => QuantitySearchValue.Parse(s)); + Assert.Throws(() => QuantitySearchValue.Parse(s)); } [Fact] diff --git a/src/Microsoft.Health.Fhir.Core/Features/Search/SearchValues/QuantitySearchValue.cs b/src/Microsoft.Health.Fhir.Core/Features/Search/SearchValues/QuantitySearchValue.cs index b424f1800a..95a26cc0ff 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Search/SearchValues/QuantitySearchValue.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Search/SearchValues/QuantitySearchValue.cs @@ -8,6 +8,7 @@ using System.Globalization; using System.Text; using EnsureThat; +using Microsoft.Health.Fhir.Core.Features.Persistence; namespace Microsoft.Health.Fhir.Core.Features.Search.SearchValues { @@ -63,7 +64,12 @@ public static QuantitySearchValue Parse(string s) throw new FormatException(Core.Resources.MoreThanTwoTokenSeparatorSpecified); } - decimal quantity = decimal.Parse(parts[0], NumberStyles.Number, CultureInfo.InvariantCulture); + decimal quantity; + if (!decimal.TryParse(parts[0], NumberStyles.Number, CultureInfo.InvariantCulture, out quantity)) + { + throw new BadRequestException(string.Format(Core.Resources.MalformedSearchValue, parts[0])); + } + string system = parts.Count > 1 ? parts[1] : string.Empty; string code = parts.Count > 2 ? parts[2] : string.Empty; diff --git a/src/Microsoft.Health.Fhir.Core/Resources.Designer.cs b/src/Microsoft.Health.Fhir.Core/Resources.Designer.cs index 061ec6cd4d..882b6c5d55 100644 --- a/src/Microsoft.Health.Fhir.Core/Resources.Designer.cs +++ b/src/Microsoft.Health.Fhir.Core/Resources.Designer.cs @@ -10,48 +10,35 @@ namespace Microsoft.Health.Fhir.Core { using System; + using System.Reflection; - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { - private static global::System.Resources.ResourceManager resourceMan; + private static System.Resources.ResourceManager resourceMan; - private static global::System.Globalization.CultureInfo resourceCulture; + private static System.Globalization.CultureInfo resourceCulture; - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Resources.ResourceManager ResourceManager { get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Health.Fhir.Core.Resources", typeof(Resources).Assembly); + if (object.Equals(null, resourceMan)) { + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Microsoft.Health.Fhir.Core.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -60,621 +47,420 @@ internal Resources() { } } - /// - /// Looks up a localized string similar to {0} and {1} cannot both be specified.. - /// internal static string AtAndSinceCannotBeBothSpecified { get { return ResourceManager.GetString("AtAndSinceCannotBeBothSpecified", resourceCulture); } } - /// - /// Looks up a localized string similar to The authorization permission definition contains one or more invalid entries.. - /// internal static string AuthorizationPermissionDefinitionInvalid { get { return ResourceManager.GetString("AuthorizationPermissionDefinitionInvalid", resourceCulture); } } - /// - /// Looks up a localized string similar to CapabilityStatement must have only a single item in the 'Rest' collection.. - /// internal static string CapabilityStatementSingleRestItem { get { return ResourceManager.GetString("CapabilityStatementSingleRestItem", resourceCulture); } } - /// - /// Looks up a localized string similar to The chained parameter must be a reference search parameter type.. - /// internal static string ChainedParameterMustBeReferenceSearchParamType { get { return ResourceManager.GetString("ChainedParameterMustBeReferenceSearchParamType", resourceCulture); } } - /// - /// Looks up a localized string similar to The chained parameter is not supported.. - /// internal static string ChainedParameterNotSupported { get { return ResourceManager.GetString("ChainedParameterNotSupported", resourceCulture); } } - /// - /// Looks up a localized string similar to Comparator '{0}' is not supported for search parameter '{1}'.. - /// internal static string ComparatorNotSupported { get { return ResourceManager.GetString("ComparatorNotSupported", resourceCulture); } } - /// - /// Looks up a localized string similar to The compartment definition contains one or more invalid entries.. - /// internal static string CompartmentDefinitionContainsInvalidEntry { get { return ResourceManager.GetString("CompartmentDefinitionContainsInvalidEntry", resourceCulture); } } - /// - /// Looks up a localized string similar to bundle.entry[{0}].resource has duplicate resources.. - /// internal static string CompartmentDefinitionDupeResource { get { return ResourceManager.GetString("CompartmentDefinitionDupeResource", resourceCulture); } } - /// - /// Looks up a localized string similar to bundle.entry[{0}] is null.. - /// internal static string CompartmentDefinitionInvalidBundle { get { return ResourceManager.GetString("CompartmentDefinitionInvalidBundle", resourceCulture); } } - /// - /// Looks up a localized string similar to bundle.entry[{0}].resource.code is null. Not a valid compartment type.. - /// internal static string CompartmentDefinitionInvalidCompartmentType { get { return ResourceManager.GetString("CompartmentDefinitionInvalidCompartmentType", resourceCulture); } } - /// - /// Looks up a localized string similar to bundle.entry[{0}].resource is null or is not a CompartmentDefinition resource.. - /// internal static string CompartmentDefinitionInvalidResource { get { return ResourceManager.GetString("CompartmentDefinitionInvalidResource", resourceCulture); } } - /// - /// Looks up a localized string similar to bundle.entry[{0}].resource.url is invalid.. - /// internal static string CompartmentDefinitionInvalidUrl { get { return ResourceManager.GetString("CompartmentDefinitionInvalidUrl", resourceCulture); } } - /// - /// Looks up a localized string similar to bundle.entry[{0}].resource has duplicate compartment definitions.. - /// internal static string CompartmentDefinitionIsDupe { get { return ResourceManager.GetString("CompartmentDefinitionIsDupe", resourceCulture); } } - /// - /// Looks up a localized string similar to Compartment id is null or empty.. - /// internal static string CompartmentIdIsInvalid { get { return ResourceManager.GetString("CompartmentIdIsInvalid", resourceCulture); } } - /// - /// Looks up a localized string similar to Compartment type {0} is invalid.. - /// internal static string CompartmentTypeIsInvalid { get { return ResourceManager.GetString("CompartmentTypeIsInvalid", resourceCulture); } } - /// - /// Looks up a localized string similar to The composite separator cannot be found.. - /// internal static string CompositeSeparatorNotFound { get { return ResourceManager.GetString("CompositeSeparatorNotFound", resourceCulture); } } - /// - /// Looks up a localized string similar to Deleting a specific record version is not supported.. - /// internal static string DeleteVersionNotAllowed { get { return ResourceManager.GetString("DeleteVersionNotAllowed", resourceCulture); } } - /// - /// Looks up a localized string similar to Id must be any combination of upper or lower case ASCII letters ('A'..'Z', and 'a'..'z'), numerals ('0'..'9'), '-' and '.', with a length limit of 64 characters. (This might be an integer, an un-prefixed OID, UUID, or any other identifier pattern that meets these constraints.). - /// internal static string IdRequirements { get { return ResourceManager.GetString("IdRequirements", resourceCulture); } } - /// - /// Looks up a localized string similar to A valid if-match header is required for resource type '{0}'.. - /// internal static string IfMatchHeaderRequiredForResource { get { return ResourceManager.GetString("IfMatchHeaderRequiredForResource", resourceCulture); } } - /// - /// Looks up a localized string similar to Illegal attribute name '{0}' on element '{1}'.. - /// internal static string IllegalHtmlAttribute { get { return ResourceManager.GetString("IllegalHtmlAttribute", resourceCulture); } } - /// - /// Looks up a localized string similar to Illegal element name '{0}'.. - /// internal static string IllegalHtmlElement { get { return ResourceManager.GetString("IllegalHtmlElement", resourceCulture); } } - /// - /// Looks up a localized string similar to The div element must not be empty or only whitespace.. - /// internal static string IllegalHtmlEmpty { get { return ResourceManager.GetString("IllegalHtmlEmpty", resourceCulture); } } - /// - /// Looks up a localized string similar to XHTML content should be contained within a single <div> element.. - /// internal static string IllegalHtmlOuterDiv { get { return ResourceManager.GetString("IllegalHtmlOuterDiv", resourceCulture); } } - /// - /// Looks up a localized string similar to Error while parsing XHTML: {0} Line: {1} Col: {2}.. - /// internal static string IllegalHtmlParsingError { get { return ResourceManager.GetString("IllegalHtmlParsingError", resourceCulture); } } - /// - /// Looks up a localized string similar to Field '{0}' with value '{1}' is not supported.. - /// internal static string InvalidBooleanConfigSetting { get { return ResourceManager.GetString("InvalidBooleanConfigSetting", resourceCulture); } } - /// - /// Looks up a localized string similar to The continuation token is invalid.. - /// internal static string InvalidContinuationToken { get { return ResourceManager.GetString("InvalidContinuationToken", resourceCulture); } } - /// - /// Looks up a localized string similar to Field '{0}' with value '{1}' is not supported. Please select from the following list of supported capabilities: [{2}].. - /// internal static string InvalidEnumConfigSetting { get { return ResourceManager.GetString("InvalidEnumConfigSetting", resourceCulture); } } - /// - /// Looks up a localized string similar to A duplicate value was found for field '{0}'. Please check your configured options.. - /// internal static string InvalidListConfigDuplicateItem { get { return ResourceManager.GetString("InvalidListConfigDuplicateItem", resourceCulture); } } - /// - /// Looks up a localized string similar to Unsupported values for field '{0}' were selected. Please check your configured options.. - /// internal static string InvalidListConfigSetting { get { return ResourceManager.GetString("InvalidListConfigSetting", resourceCulture); } } - /// - /// Looks up a localized string similar to The count must be greater than zero.. - /// internal static string InvalidSearchCountSpecified { get { return ResourceManager.GetString("InvalidSearchCountSpecified", resourceCulture); } } - /// - /// Looks up a localized string similar to Invalid value for :missing modifier. Valid values are: true, false.. - /// internal static string InvalidValueTypeForMissingModifier { get { return ResourceManager.GetString("InvalidValueTypeForMissingModifier", resourceCulture); } } - /// - /// Looks up a localized string similar to Modifier '{0}' is not supported for search parameter '{1}'.. - /// + internal static string MalformedSearchValue { + get { + return ResourceManager.GetString("MalformedSearchValue", resourceCulture); + } + } + internal static string ModifierNotSupported { get { return ResourceManager.GetString("ModifierNotSupported", resourceCulture); } } - /// - /// Looks up a localized string similar to Only one token separator can be specified.. - /// internal static string MoreThanOneTokenSeparatorSpecified { get { return ResourceManager.GetString("MoreThanOneTokenSeparatorSpecified", resourceCulture); } } - /// - /// Looks up a localized string similar to No more than two token separators can be specified.. - /// internal static string MoreThanTwoTokenSeparatorSpecified { get { return ResourceManager.GetString("MoreThanTwoTokenSeparatorSpecified", resourceCulture); } } - /// - /// Looks up a localized string similar to Query parameter '{0}' cannot be specified more than once.. - /// internal static string MultipleQueryParametersNotAllowed { get { return ResourceManager.GetString("MultipleQueryParametersNotAllowed", resourceCulture); } } - /// - /// Looks up a localized string similar to The number of composite components specified for search parameter '{0}' exceeded the number of components defined.. - /// internal static string NumberOfCompositeComponentsExceeded { get { return ResourceManager.GetString("NumberOfCompositeComponentsExceeded", resourceCulture); } } - /// - /// Looks up a localized string similar to Only equal comparator is supported for this search type.. - /// internal static string OnlyEqualComparatorIsSupported { get { return ResourceManager.GetString("OnlyEqualComparatorIsSupported", resourceCulture); } } - /// - /// Looks up a localized string similar to Only one modifier separator can be specified.. - /// internal static string OnlyOneModifierSeparatorSupported { get { return ResourceManager.GetString("OnlyOneModifierSeparatorSupported", resourceCulture); } } - /// - /// Looks up a localized string similar to Failed to retrieve the OpenId configuration from the authentication provider.. - /// internal static string OpenIdConfiguration { get { return ResourceManager.GetString("OpenIdConfiguration", resourceCulture); } } - /// - /// Looks up a localized string similar to ReadHistory is disabled for resources of type '{0}'.. - /// internal static string ReadHistoryDisabled { get { return ResourceManager.GetString("ReadHistoryDisabled", resourceCulture); } } - /// - /// Looks up a localized string similar to The requested action is not allowed.. - /// internal static string RequestedActionNotAllowed { get { return ResourceManager.GetString("RequestedActionNotAllowed", resourceCulture); } } - /// - /// Looks up a localized string similar to The request rate has exceeded the maximum API request rate and is being throttled. Please try again later.. - /// internal static string RequestRateExceeded { get { return ResourceManager.GetString("RequestRateExceeded", resourceCulture); } } - /// - /// Looks up a localized string similar to Resource creation is not allowed.. - /// internal static string ResourceCreationNotAllowed { get { return ResourceManager.GetString("ResourceCreationNotAllowed", resourceCulture); } } - /// - /// Looks up a localized string similar to Resource type '{0}' with id '{1}' couldn't be found.. - /// internal static string ResourceNotFoundById { get { return ResourceManager.GetString("ResourceNotFoundById", resourceCulture); } } - /// - /// Looks up a localized string similar to Resource type '{0}' with id '{1}' and version '{2}' couldn't be found.. - /// internal static string ResourceNotFoundByIdAndVersion { get { return ResourceManager.GetString("ResourceNotFoundByIdAndVersion", resourceCulture); } } - /// - /// Looks up a localized string similar to Resource type '{0}' is not supported.. - /// internal static string ResourceNotSupported { get { return ResourceManager.GetString("ResourceNotSupported", resourceCulture); } } - /// - /// Looks up a localized string similar to Role '{0}' must have one or more ResourcePermissions.. - /// internal static string ResourcePermissionEmpty { get { return ResourceManager.GetString("ResourcePermissionEmpty", resourceCulture); } } - /// - /// Looks up a localized string similar to The supplied version '{0}' did not match.. - /// internal static string ResourceVersionConflict { get { return ResourceManager.GetString("ResourceVersionConflict", resourceCulture); } } - /// - /// Looks up a localized string similar to Role name cannot be null or empty.. - /// internal static string RoleNameEmpty { get { return ResourceManager.GetString("RoleNameEmpty", resourceCulture); } } - /// - /// Looks up a localized string similar to Role '{0}' contains a ResourcePermission with no Actions.. - /// internal static string RoleResourcePermissionWithNoAction { get { return ResourceManager.GetString("RoleResourcePermissionWithNoAction", resourceCulture); } } - /// - /// Looks up a localized string similar to Comparator is not supported when multiple values are specified using OR search parameter.. - /// internal static string SearchComparatorNotSupported { get { return ResourceManager.GetString("SearchComparatorNotSupported", resourceCulture); } } - /// - /// Looks up a localized string similar to The search parameter with definition URL '{0}' is not supported.. - /// internal static string SearchParameterByDefinitionUriNotSupported { get { return ResourceManager.GetString("SearchParameterByDefinitionUriNotSupported", resourceCulture); } } - /// - /// Looks up a localized string similar to bundle.entry[{0}].resource.base is not defined.. - /// internal static string SearchParameterDefinitionBaseNotDefined { get { return ResourceManager.GetString("SearchParameterDefinitionBaseNotDefined", resourceCulture); } } - /// - /// Looks up a localized string similar to bundle.entry[{0}].component[{1}] cannot refer to a composite SearchParameter.. - /// internal static string SearchParameterDefinitionComponentReferenceCannotBeComposite { get { return ResourceManager.GetString("SearchParameterDefinitionComponentReferenceCannotBeComposite", resourceCulture); } } - /// - /// Looks up a localized string similar to The search parameter definition contains one or more invalid entries.. - /// internal static string SearchParameterDefinitionContainsInvalidEntry { get { return ResourceManager.GetString("SearchParameterDefinitionContainsInvalidEntry", resourceCulture); } } - /// - /// Looks up a localized string similar to A search parameter with the same definition URL '{0}' already exists.. - /// internal static string SearchParameterDefinitionDuplicatedEntry { get { return ResourceManager.GetString("SearchParameterDefinitionDuplicatedEntry", resourceCulture); } } - /// - /// Looks up a localized string similar to bundle.entry[{0}].component is null or empty.. - /// internal static string SearchParameterDefinitionInvalidComponent { get { return ResourceManager.GetString("SearchParameterDefinitionInvalidComponent", resourceCulture); } } - /// - /// Looks up a localized string similar to bundle.entry[{0}].component[{1}].expression is null or empty.. - /// internal static string SearchParameterDefinitionInvalidComponentExpression { get { return ResourceManager.GetString("SearchParameterDefinitionInvalidComponentExpression", resourceCulture); } } - /// - /// Looks up a localized string similar to bundle.entry[{0}].component[{1}].definition.reference is null or empty or does not refer to a valid SearchParameter resource.. - /// internal static string SearchParameterDefinitionInvalidComponentReference { get { return ResourceManager.GetString("SearchParameterDefinitionInvalidComponentReference", resourceCulture); } } - /// - /// Looks up a localized string similar to bundle.entry[{0}].url is invalid.. - /// internal static string SearchParameterDefinitionInvalidDefinitionUri { get { return ResourceManager.GetString("SearchParameterDefinitionInvalidDefinitionUri", resourceCulture); } } - /// - /// Looks up a localized string similar to bundle.entry[{0}].resource.expression is null or empty.. - /// internal static string SearchParameterDefinitionInvalidExpression { get { return ResourceManager.GetString("SearchParameterDefinitionInvalidExpression", resourceCulture); } } - /// - /// Looks up a localized string similar to bundle.entry[{0}].resource is not a SearchParameter resource.. - /// internal static string SearchParameterDefinitionInvalidResource { get { return ResourceManager.GetString("SearchParameterDefinitionInvalidResource", resourceCulture); } } - /// - /// Looks up a localized string similar to The search parameter '{0}' is not supported for resource type '{1}'.. - /// internal static string SearchParameterNotSupported { get { return ResourceManager.GetString("SearchParameterNotSupported", resourceCulture); } } - /// - /// Looks up a localized string similar to Microsoft FHIR Server. - /// internal static string ServerName { get { return ResourceManager.GetString("ServerName", resourceCulture); } } - /// - /// Looks up a localized string similar to The operation could not be completed, because the service was unable to accept new requests. It is safe to retry the operation. If the issue persists, please contact support.. - /// internal static string ServiceUnavailable { get { return ResourceManager.GetString("ServiceUnavailable", resourceCulture); } } - /// - /// Looks up a localized string similar to Unsupported configuration found.. - /// internal static string UnsupportedConfigurationMessage { get { return ResourceManager.GetString("UnsupportedConfigurationMessage", resourceCulture); } } - /// - /// Looks up a localized string similar to Resource id is required for updates.. - /// internal static string UpdateRequestsRequireId { get { return ResourceManager.GetString("UpdateRequestsRequireId", resourceCulture); } } - /// - /// Looks up a localized string similar to VersionId should not be in the weak ETag format.. - /// internal static string VersionIdFormatNotETag { get { return ResourceManager.GetString("VersionIdFormatNotETag", resourceCulture); } } - /// - /// Looks up a localized string similar to WeakETag must be in the weak ETag format.. - /// internal static string WeakETagFormatRequired { get { return ResourceManager.GetString("WeakETagFormatRequired", resourceCulture); diff --git a/src/Microsoft.Health.Fhir.Core/Resources.resx b/src/Microsoft.Health.Fhir.Core/Resources.resx index 05701ddb63..8491a0580a 100644 --- a/src/Microsoft.Health.Fhir.Core/Resources.resx +++ b/src/Microsoft.Health.Fhir.Core/Resources.resx @@ -211,6 +211,9 @@ Invalid value for :missing modifier. Valid values are: true, false. + + Malformed search value '{0}'. + Modifier '{0}' is not supported for search parameter '{1}'.