fix(core): Handle Umbraco slider {from,to} shape in double config fields#147
Merged
Merged
Conversation
…fig fields
Umbraco's `Umb.PropertyEditorUi.Slider` serialises its value as `{from, to}`
rather than a plain number, causing System.Text.Json to throw "The JSON value
could not be converted to System.Double" when deserialising guardrail/grader
configs that expose a slider-bound double (e.g. `safetyThreshold`,
`passThreshold`).
Add `SliderDoubleJsonConverter` that accepts a JSON number, a numeric string,
or a slider object (extracting `from`), and apply it to `SafetyThreshold` on
`LLMGuardrailEvaluatorConfig` and `PassThreshold` on `LLMJudgeGraderConfig`.
Also corrects the slider editor config aliases on those fields - the slider
property editor reads `minVal`/`maxVal`, not `minValue`/`maxValue`, so the
range previously fell back to the 0-100 default instead of 0-1.
Fixes #146
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #146 — saving an LLM Safety Judge guardrail rule produces "The JSON value could not be converted to System.Double. Path: $.safetyThreshold" when the guardrail is later evaluated.
Root cause:
Umb.PropertyEditorUi.Sliderserialises its value as{ "from": n, "to": n }, not a plain number. The C# propertySafetyThresholdis typed asdouble, so System.Text.Json fails on deserialization. TheContainsandRegexevaluators don't hit this because they bind to text editors. The same latent bug exists onLLMJudgeGraderConfig.PassThreshold.Fix:
SliderDoubleJsonConverterthat accepts a JSON number, a numeric string, or the slider{from, to}object (extractingfrom).[JsonConverter(...)]toSafetyThresholdandPassThreshold.EditorConfigaliases — the property editor readsminVal/maxVal, notminValue/maxValue, so the slider previously fell back to a 0–100 range instead of 0–1. AddedinitVal1=0.7so the slider initialises at the C# default.Test plan
SliderDoubleJsonConverterTests(7 cases: number / string-number / slider object / range / missingfrom/ non-numeric / write)🤖 Generated with Claude Code