babalae/better-genshin-impact · error · ArgumentException
Invalid key format for sctp.
Error message
Invalid key format for sctp.
What it means
ArgumentException thrown by GetServerChanApiUrl when the SendKey starts with "sctp" but does not match the regex ^sctp(\d+)t (e.g. sctpABCDt, sctp123x). The sctp format is sctp{number}t{rest}; without the numeric segment the ft07 endpoint number cannot be derived. NOTE: because this is thrown inside SendAsync's try, it is normally swallowed and re-emerged as the generic error-530 message.
Source
Thrown at BetterGenshinImpact/Service/Notifier/ServerChanNotifier.cs:87
}
/// <summary>
/// 根据sendKey格式获取正确的API URL
/// </summary>
private string GetServerChanApiUrl(string key)
{
// 判断sendkey是否以"sctp"开头并提取数字部分
if (key.StartsWith("sctp"))
{
var match = Regex.Match(key, @"^sctp(\d+)t");
if (match.Success)
{
var num = match.Groups[1].Value;
return $"https://{num}.push.ft07.com/send/{key}.send";
}
else
{
throw new ArgumentException("Invalid key format for sctp.");
}
}
else
{
return $"https://sctapi.ftqq.com/{key}.send";
}
}
/// <summary>
/// 生成通知描述内容
/// </summary>
private string GenerateDescription(BaseNotificationData data)
{
var sb = new StringBuilder();
// 添加事件时间
sb.AppendLine($"**时间**: {data.Timestamp.ToString("yyyy-MM-dd HH:mm:ss")}");
View on GitHub (pinned to a7cb36712d)
Solutions
- Re-copy the full sctp key from the ft07 dashboard, ensuring it matches sctp{digits}t{token}.
- Loosen or clarify the regex if the official format changed, and surface a clear message.
- Move format validation to construction time so the user sees the specific error rather than the catch-all 530 wrapper.
Example fix
// before
if (key.StartsWith("sctp"))
{
var match = Regex.Match(key, @"^sctp(\d+)t");
if (match.Success) { ... }
else throw new ArgumentException("Invalid key format for sctp.");
}
// after — clearer message and validate before the network try-block
var match = Regex.Match(key, @"^sctp(\d+)t");
if (!match.Success)
throw new ArgumentException("sctp SendKey 必须形如 sctp<数字>t<token>,当前值不符合: " + key);
var num = match.Groups[1].Value;
return $"https://{num}.push.ft07.com/send/{key}.send"; Defensive patterns
Strategy: validation
Validate before calling
if (sendKey.StartsWith("sctp") && !Regex.IsMatch(sendKey, @"^sctp\d+t"))
throw new InvalidOperationException($"sctp SendKey must match sctp<digits>t<token>: '{sendKey}'"); Type guard
static bool IsValidSctpKey(string key)
=> !key.StartsWith("sctp") || Regex.IsMatch(key, @"^sctp\d+t"); Try / catch
try { string url = GetServerChanApiUrl(sendKey); }
catch (ArgumentException ex) when (ex.Message.Contains("sctp"))
{ /* prompt user to re-copy the ft07 SendKey, no retry */ } Prevention
- Validate the sctp key format at settings-save time, not just at send time.
- Show the expected format (sctp<digits>t<token>) in the UI.
- Re-copy the full key from the ft07 dashboard.
When it happens
Trigger: key.StartsWith("sctp") is true but Regex.Match(key, @"^sctp(\d+)t") fails (no digits between sctp and t).
Common situations: User pasted a ServerChanTurbo 2024 key with a typo; trailing/leading characters; copied only part of the key; legacy non-numeric sctp variant the regex does not anticipate.
Related errors
- ServerChan SendKey为空
- MeoW 昵称为空
- OneBot endpoint is not set
- OneBot requires either a user ID or group ID
- Invalid Telegram proxy URL format: {proxyUrl}. Details: {ex.
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/a2c3b16f99371389.
Report an issue: GitHub.