diff --git a/libdd-ffe-ffi/src/assignment.rs b/libdd-ffe-ffi/src/assignment.rs index 1b4e935df1..6f4de82381 100644 --- a/libdd-ffe-ffi/src/assignment.rs +++ b/libdd-ffe-ffi/src/assignment.rs @@ -370,7 +370,7 @@ impl From<&ResolutionDetails> for Reason { Ok(assignment) => assignment.reason.into(), Err(EvaluationError::FlagDisabled) => Reason::Disabled, Err(EvaluationError::DefaultAllocationNull) => Reason::Default, - Err(EvaluationError::FlagConfigurationInvalid) => Reason::Default, + Err(EvaluationError::FlagConfigurationInvalid) => Reason::Error, Err(_) => Reason::Error, } } @@ -409,7 +409,7 @@ impl From<&EvaluationError> for ErrorCode { EvaluationError::TypeMismatch { .. } => ErrorCode::TypeMismatch, EvaluationError::TargetingKeyMissing => ErrorCode::TargetingKeyMissing, EvaluationError::ConfigurationParseError => ErrorCode::ParseError, - EvaluationError::FlagConfigurationInvalid => ErrorCode::Ok, + EvaluationError::FlagConfigurationInvalid => ErrorCode::ParseError, EvaluationError::ConfigurationMissing => ErrorCode::ProviderNotReady, EvaluationError::FlagUnrecognizedOrDisabled => ErrorCode::FlagNotFound, EvaluationError::FlagDisabled => ErrorCode::Ok, @@ -486,3 +486,24 @@ pub unsafe extern "C" fn ddog_ffe_assignment_drop(assignment: *mut Handle &'static str { fn reason_from_error(err: &EvaluationError) -> &'static str { match err { EvaluationError::FlagDisabled => "DISABLED", - EvaluationError::DefaultAllocationNull | EvaluationError::FlagConfigurationInvalid => { - "DEFAULT" - } + EvaluationError::DefaultAllocationNull => "DEFAULT", _ => "ERROR", } } fn error_code_from_error(err: &EvaluationError) -> Option<&'static str> { match err { - EvaluationError::FlagDisabled - | EvaluationError::DefaultAllocationNull - | EvaluationError::FlagConfigurationInvalid => None, + EvaluationError::FlagDisabled | EvaluationError::DefaultAllocationNull => None, + EvaluationError::FlagConfigurationInvalid => Some("PARSE_ERROR"), EvaluationError::TypeMismatch { .. } => Some("TYPE_MISMATCH"), EvaluationError::TargetingKeyMissing => Some("TARGETING_KEY_MISSING"), EvaluationError::ConfigurationParseError => Some("PARSE_ERROR"), diff --git a/libdd-ffe/src/rules_based/eval/eval_rules.rs b/libdd-ffe/src/rules_based/eval/eval_rules.rs index 375414cbdc..1fdc7c17cb 100644 --- a/libdd-ffe/src/rules_based/eval/eval_rules.rs +++ b/libdd-ffe/src/rules_based/eval/eval_rules.rs @@ -67,7 +67,7 @@ impl ConditionCheck { } => { let attr_str = attribute?.as_str()?; let attr_version = semver::Version::parse(attr_str.as_ref()).ok()?; - let ordering = attr_version.cmp(comparand); + let ordering = attr_version.cmp_precedence(comparand); match operator { SemverComparisonOperator::Eq => ordering.is_eq(), SemverComparisonOperator::Neq => !ordering.is_eq(), @@ -386,6 +386,15 @@ mod tests { assert!(!check.eval(Some(&"1.0.0".into()))); } + #[test] + fn semver_build_metadata_does_not_affect_precedence() { + let check = ConditionCheck::SemverComparison { + operator: SemverComparisonOperator::Eq, + comparand: semver("1.0.0"), + }; + assert!(check.eval(Some(&"1.0.0+build.42".into()))); + } + #[test] fn semver_invalid_attribute_returns_false() { let check = ConditionCheck::SemverComparison {