lyswhut/lx-music-desktop · error · Error
${rule.key} type no match
Error message
${rule.key} type no match What it means
dataVerify (utils.js:38) checks each non-null value's `typeof` against the rule's `types` array. A mismatch throws '<key> type no match'. For example, a `types` field sent as a string instead of an object, or `interval` as a number when only ['string'] is permitted, trips this guard.
Source
Thrown at src/renderer/core/useApp/useDeeplink/utils.js:38
export const qualitys = ['128k', '320k', 'flac', 'flac24bit']
export const qualityFilter = (source, types) => {
types = types.filter(({ type }) => qualitys.includes(type)).map(({ type, size, hash }) => {
if (size != null && typeof size != 'string') throw new Error(type + ' size type no match')
if (source == 'kg' && typeof hash != 'string') throw new Error(type + ' hash type no match')
return hash == null ? { type, size } : { type, size, hash }
})
if (!types.length) throw new Error('quality no match')
return types
}
export const dataVerify = (rules, data) => {
const newData = {}
for (const rule of rules) {
const val = data[rule.key]
if (rule.required && val == null) throw new Error(rule.key + ' missing')
if (val != null) {
if (rule.types && !rule.types.includes(typeof val)) throw new Error(rule.key + ' type no match')
if (rule.max && String(val).length > rule.max) throw new Error(rule.key + ' max length no match')
if (rule.min && String(val).length > rule.min) throw new Error(rule.key + ' min length no match')
}
newData[rule.key] = val
}
return newData
}
View on GitHub (pinned to 9c364b482e)
Solutions
- Align the sender's primitive type with the rule's `types` array.
- Broaden the rule (e.g. add 'number') if both primitives are acceptable for that field.
- Coerce the value to an accepted type before validation.
- Inspect the interpolated key name to find the exact field, then check its rule in useMusicAction.js/useSonglistAction.js.
Example fix
// before
if (rule.types && !rule.types.includes(typeof val)) throw new Error(rule.key + ' type no match')
// after - report observed vs expected for faster diagnosis
if (rule.types && !rule.types.includes(typeof val)) {
throw new Error(`${rule.key} type no match: got ${typeof val}, expected one of ${rule.types.join(', ')}`)
} Defensive patterns
Strategy: validation
Validate before calling
const findTypeMismatches = (rules, data) =>
rules.filter(r => data[r.key] != null && r.types && !r.types.includes(typeof data[r.key])).map(r => r.key)
const bad = findTypeMismatches(rules, data)
if (bad.length) {
showErrorDialog(`Wrong type for field(s): ${bad.join(', ')}`)
return
} Type guard
const matchesRuleType = (rule, data) => {
const v = data[rule.key]
return v == null || !rule.types || rule.types.includes(typeof v)
} Try / catch
try {
info = dataVerify(rules, info)
} catch (e) {
errorDialog(e.message)
} Prevention
- Coerce fields to an accepted primitive at the boundary (e.g. String(interval)) when the sender's type differs.
- Where both string and number are fine, list both in the rule's `types`.
- Inspect the interpolated key to find the offending field fast.
When it happens
Trigger: A field whose runtime type is not in the allowed set — e.g. musicInfo.types is a JSON string rather than an array/object; songInterval is a number but the rule only lists 'string'. Note: typeof for arrays/objects is both 'object', so array-vs-object is not distinguished here.
Common situations: Loosely-typed JSON where the sender used a different primitive; numeric fields sent as strings when the rule only allows 'number' (many rules defensively allow both 'string' and 'number'); a field double-encoded as a stringified JSON.
Related errors
- ${type} size type no match
- ${rule.key} max length no match
- Unknown source: ${musicInfo.source}
- Unknown action: ${action}
- Unknown action: ${action}
AI-assisted analysis of lyswhut/lx-music-desktop@9c364b482e (2026-08-12).
Data as JSON: /api/errors/00ffd49709e1586e.
Report an issue: GitHub.