Skip to content

fix(core): Handle Umbraco slider {from,to} shape in double config fields#147

Merged
mattbrailsford merged 1 commit into
devfrom
feature/fix-slider-deserialization
May 5, 2026
Merged

fix(core): Handle Umbraco slider {from,to} shape in double config fields#147
mattbrailsford merged 1 commit into
devfrom
feature/fix-slider-deserialization

Conversation

@mattbrailsford
Copy link
Copy Markdown
Contributor

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.Slider serialises its value as { "from": n, "to": n }, not a plain number. The C# property SafetyThreshold is typed as double, so System.Text.Json fails on deserialization. The Contains and Regex evaluators don't hit this because they bind to text editors. The same latent bug exists on LLMJudgeGraderConfig.PassThreshold.

Fix:

  • Added SliderDoubleJsonConverter that accepts a JSON number, a numeric string, or the slider {from, to} object (extracting from).
  • Applied via [JsonConverter(...)] to SafetyThreshold and PassThreshold.
  • Corrected the slider's EditorConfig aliases — the property editor reads minVal/maxVal, not minValue/maxValue, so the slider previously fell back to a 0–100 range instead of 0–1. Added initVal1=0.7 so the slider initialises at the C# default.

Test plan

  • New unit tests in SliderDoubleJsonConverterTests (7 cases: number / string-number / slider object / range / missing from / non-numeric / write)
  • Existing guardrail + grader + editable-model tests still green (72 tests)
  • Manual verification: create LLM Safety Judge guardrail, attach to Backoffice Copilot agent, send a message — no deserialization error

🤖 Generated with Claude Code

…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
@mattbrailsford mattbrailsford merged commit 5efa400 into dev May 5, 2026
21 of 24 checks passed
@mattbrailsford mattbrailsford deleted the feature/fix-slider-deserialization branch May 5, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Guardrails] LLM Safety Judge safetyThreshold causes runtime error "JSON value could not be converted to System.Double"

1 participant