@@ -150,7 +150,7 @@ def create_success_result(value, variant, allocation_key, variation_type, do_log
150150 variant : variant ,
151151 error_code : nil , # nil for successful cases (so "if result.error_code" works correctly)
152152 error_message : '' , # Empty string for Ok cases (matches libdatadog FFI)
153- reason : convert_reason_to_symbol ( reason ) ,
153+ reason : reason ,
154154 allocation_key : allocation_key ,
155155 do_log : do_log ,
156156 flag_metadata : {
@@ -170,11 +170,14 @@ def create_error_result(error_code, error_message)
170170 ERROR_CODE_MAPPING [ error_code ] || :general
171171 end
172172
173- # Determine reason based on error type
174- reason = if [ Ext ::DEFAULT_ALLOCATION_NULL , Ext ::FLAG_DISABLED ] . include? ( error_code )
175- :static # These are expected conditions, not errors
173+ # Determine reason based on error type - aligned with libdatadog FFI Reason enum
174+ reason = case error_code
175+ when Ext ::DEFAULT_ALLOCATION_NULL
176+ AssignmentReason ::DEFAULT
177+ when Ext ::FLAG_DISABLED
178+ AssignmentReason ::DISABLED
176179 else
177- :error
180+ AssignmentReason :: ERROR
178181 end
179182
180183 ResolutionDetails . new (
@@ -511,25 +514,6 @@ def convert_variation_type_for_output(variation_type)
511514 VARIATION_TYPE_MAPPING [ variation_type ] || variation_type . to_s . downcase
512515 end
513516
514- def convert_reason_to_symbol ( reason )
515- # Convert assignment reasons to string format matching libdatadog Reason enum
516- case reason
517- when AssignmentReason ::STATIC
518- 'STATIC'
519- when AssignmentReason ::TARGETING_MATCH
520- 'TARGETING_MATCH'
521- when AssignmentReason ::SPLIT
522- 'SPLIT'
523- when 'ERROR'
524- 'ERROR'
525- when 'DEFAULT'
526- 'DEFAULT'
527- when 'DISABLED'
528- 'DISABLED'
529- else
530- reason . to_s if reason
531- end
532- end
533517
534518 end
535519 end
0 commit comments