Devolutions/UniGetUI · error · InvalidOperationException
Provide exactly one of enabled or value when setting a setti
Error message
Provide exactly one of enabled or value when setting a setting.
What it means
Thrown by SetSetting when the caller provides both Enabled and Value, or neither, on the IpcSettingValueRequest. The API is designed as a discriminated union: boolean settings use Settings.Set (file existence) and string settings use Settings.SetValue (file content). The check hasEnabled == hasValue catches both the both-set and neither-set cases simultaneously.
Source
Thrown at src/UniGetUI.Interface.IpcApi/IpcManagerSettingsApi.cs:165
.ToArray();
}
public static IpcSettingInfo GetSetting(string settingKey)
{
return ToSettingInfo(ResolveSettingKey(settingKey));
}
public static IpcSettingInfo SetSetting(IpcSettingValueRequest request)
{
ArgumentNullException.ThrowIfNull(request);
var key = ResolveSettingKey(request.SettingKey);
var hasEnabled = request.Enabled.HasValue;
var hasValue = request.Value is not null;
if (hasEnabled == hasValue)
{
throw new InvalidOperationException(
"Provide exactly one of enabled or value when setting a setting."
);
}
if (hasValue)
{
Settings.SetValue(key, request.Value ?? "");
}
else
{
Settings.Set(key, request.Enabled!.Value);
}
return ToSettingInfo(key);
}
public static IpcSettingInfo ClearSetting(string settingKey)
{View on GitHub (pinned to 9b1d7d0eab)
Solutions
- For boolean settings: set Enabled to true/false and leave Value null.
- For string settings: set Value to the desired string and leave Enabled null.
- Inspect the setting type via ListSettings() — if IsSet/BoolValue semantics apply, use Enabled; if StringValue/HasStringValue apply, use Value.
Example fix
// before — ambiguous request
var req = new IpcSettingValueRequest {
SettingKey = "EnableScoopCleanup",
Enabled = true,
Value = "true" // ambiguous!
};
// after — boolean setting
var req = new IpcSettingValueRequest {
SettingKey = "EnableScoopCleanup",
Enabled = true
// Value left null
}; Defensive patterns
Strategy: validation
Validate before calling
static void ValidateSettingRequest(IpcSettingValueRequest req)
{
var hasEnabled = req.Enabled.HasValue;
var hasValue = req.Value is not null;
if (hasEnabled == hasValue)
throw new ArgumentException("Provide exactly one of Enabled or Value.");
}
ValidateSettingRequest(request); Prevention
- For boolean settings: set Enabled, leave Value null.
- For string settings: set Value, leave Enabled null.
- Never send both fields — the XOR check rejects it.
- Check ListSettings() to see which settings are boolean vs string.
When it happens
Trigger: Calling SetSetting with an IpcSettingValueRequest where Enabled.HasValue and Value is not null (both provided), or where Enabled is null and Value is null (neither provided). The XOR condition must be satisfied: exactly one must be present.
Common situations: IPC client sends a JSON payload with both fields populated (common when a UI form sends all fields). Client omits both fields entirely (default JSON deserialization gives null for both). Misunderstanding the API contract — thinking Enabled is a read-only response field rather than a write input.
Related errors
- The setting key is required.
- No setting matching "{settingKey}" was found.
- Unsupported page \"{page}\". Supported pages: {string.Join("
- The cloud backup \"{key}\" was not found.
- The backup key is required.
AI-assisted analysis of Devolutions/UniGetUI@9b1d7d0eab (2026-08-13).
Data as JSON: /api/errors/1ea45aede65805a1.
Report an issue: GitHub.