LykosAI/StabilityMatrix · warning · ValidationException
Token is required
Error message
Token is required
What it means
ConnectHuggingFace in AccountSettingsViewModel shows a password-masked token dialog whose validator throws ValidationException('Token is required') when the Hugging Face token input is null or whitespace, blocking an empty token from being stored or used for authentication.
Solutions
- Create/copy a Hugging Face access token (read scope) and paste it into the field before confirming.
- Trim whitespace from the token before submitting.
- Regenerate the token on huggingface.co if it was revoked or expired.
Example fix
// before
Validator = s => { if (string.IsNullOrWhiteSpace(s)) throw new ValidationException("Token is required"); };
// after
Validator = s => { if (string.IsNullOrWhiteSpace(s)) throw new ValidationException("Token is required");
if (!s.StartsWith("hf_")) throw new ValidationException("Token should start with hf_"); }; Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(hfToken)) {
// obtain a token from huggingface.co/settings/tokens first
return;
} Type guard
bool HasHfToken(string? s) => !string.IsNullOrWhiteSpace(s);
Try / catch
try { await viewModel.ConnectHuggingFace(); }
catch (ValidationException ex) { ShowStatus(ex.Message); } Prevention
- Generate a Hugging Face access token before connecting.
- Paste tokens immediately after copying to avoid clipboard loss.
- Trim whitespace; masked input hides empty or space-only values.
When it happens
Trigger: Submitting the 'Connect Hugging Face Account' dialog (AccountSettingsViewModel.cs:389) with an empty or whitespace-only token field.
Common situations: User clicks Connect before generating/copying a token from huggingface.co/settings/tokens; masked input hides the empty field; clipboard paste failure.
Related errors
- API key is required
- Length cannot be null when latentType is Hunyuan
- Invalid Token
- Lykos account must be connected in to manage OAuth…
- GetUserAccount did not contain an id
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/3c05f04659931ba9.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Avalonia/ViewModels/Settings/AccountSettingsViewModel.cs:389
{
return accountsService.CivitLogoutAsync();
}
[RelayCommand(CanExecute = nameof(IsInitialUpdateFinished))]
private async Task ConnectHuggingFace()
{
if (!await BeforeConnectCheck())
return;
var field = new TextBoxField
{
Label = "Hugging Face Token", // Assuming Label is for the prompt
IsPassword = true, // Assuming TextBoxField has an IsPassword property
Validator = s =>
{
if (string.IsNullOrWhiteSpace(s))
{
throw new ValidationException("Token is required");
}
},
};
var dialog = DialogHelper.CreateTextEntryDialog(
"Connect Hugging Face Account",
"Go to [Hugging Face settings](https://huggingface.co/settings/tokens) to create a new Access Token. Ensure it has read permissions. Paste the token below.",
[field]
);
var result = await dialog.ShowAsync();
if (result == ContentDialogResult.Primary && !string.IsNullOrWhiteSpace(field.Text))
{
await accountsService.HuggingFaceLoginAsync(field.Text);
await accountsService.RefreshAsync();
}
}View on GitHub (pinned to af93d6ef57)