spec: Return value and `after` stage errors
As pointed out here, the spec doesn’t dictate whether the evaluated flag value, or the default value should be returned in the case of an error in the AFTER stage hooks (4.4.7 does say: If an error occurs in the before hooks, the default value MUST be returned.).
~I think since “after” are really about side-effects, like telemetry, etc, we probably should return the evaluated value? I’d like other’s thoughts. In either case, I think we should specify this behavior.~
I think we should return the default value, to support the validation use-case @beeme1mr mentions below.
cc @justinabrahms @skyerus @moredip @beeme1mr @benjiro @kinyoklion @josecolella @tcarrio @cdonnellytx
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 18 (18 by maintainers)
I probably shouldn’t have said “dedicated validation system”. That sounds more complex than I had in mind. Basically, I think we could add support for calling a validate method during flag evaluation. That could be a new stage in a hook or a new flag evaluation option.
@beeme1mr I forgot about the “validating in the after by throwing” use case… Since we don’t allow mutation of the returned value, and this is what most SDKs have done. Maybe we should keep the current behavior and just specify it rather than making a surprise change.