maotoumao/MusicFree · warning

toast.failToImportSheet

Error message

toast.failToImportSheet

What it means

This warning toast is shown when importing a whole music sheet (playlist) via a plugin produces an empty result. The code awaits `plugin.methods.importMusicSheet(text)` and warns 'failToImportSheet' when the result is falsy or an empty array (`result && result.length > 0` fails). Like the single-item import, the await is not wrapped in try/catch, so only resolved-empty outcomes surface this message.

Source

Thrown at src/pages/setting/settingTypes/pluginSetting/components/pluginItem.tsx:175

                        Toast.success(t("toast.importing"));
                        closePanel();
                        const result = await plugin.methods.importMusicSheet(
                            text,
                        );
                        if (result && result.length > 0) {
                            showDialog("SimpleDialog", {
                                title: t("pluginSetting.pluginItem.options.importDialogTitle"),
                                content: t("pluginSetting.pluginItem.options.importSheetDialogContent", {
                                    count: result.length,
                                }),
                                onOk() {
                                    showPanel("AddToMusicSheet", {
                                        musicItem: result,
                                    });
                                },
                            });
                        } else {
                            Toast.warn(t("toast.failToImportSheet"));
                        }
                    },
                });
            },
            show: !!plugin.supportedMethods.has("importMusicSheet"),
        },
        {
            title: t("pluginSetting.pluginItem.options.userVariables"),
            icon: "code-bracket-square",
            onPress() {
                if (Array.isArray(plugin.instance.userVariables)) {
                    showPanel("SetUserVariables", {
                        async onOk(newValue, closePanel) {
                            pluginManager.setUserVariables(plugin, newValue);
                            Toast.success(t("toast.settingSuccess"));
                            closePanel();
                        },
                        variables: plugin.instance.userVariables,

View on GitHub (pinned to d118b18b3d)

Solutions

  1. Confirm the playlist is public and its URL/host matches what the plugin supports (check the panel's `hints.importMusicSheet`).
  2. Retry when network is stable; transient failures inside the plugin often surface as empty results.
  3. Update the plugin — sheet parsers frequently break when the source platform changes its API.
  4. Configure valid credentials in the plugin's user variables if the playlist requires authentication.

Example fix

// before
const result = await plugin.methods.importMusicSheet(text);
if (result && result.length > 0) { ... } else {
    Toast.warn(t("toast.failToImportSheet"));
}
// after
let result;
try {
    result = await plugin.methods.importMusicSheet(text);
} catch (e: any) {
    Toast.warn(e?.message ?? t("toast.failToImportSheet"));
    return;
}
if (Array.isArray(result) && result.length > 0) { ... } else {
    Toast.warn(t("toast.failToImportSheet"));
}
Defensive patterns

Strategy: validation

Validate before calling

const result = await plugin.methods.importMusicSheet(text);
if (!Array.isArray(result) || result.length === 0) {
    Toast.warn(t("toast.failToImportSheet"));
    return;
}

Type guard

function isNonEmptyMusicSheet(x: unknown): x is IMusicSheetItem[] {
    return Array.isArray(x) && x.length > 0 && x.every(it => !!it && typeof it === "object");
}

Try / catch

try {
    const result = await plugin.methods.importMusicSheet(text);
    if (!isNonEmptyMusicSheet(result)) throw new Error("empty sheet");
    // proceed
} catch (e: any) {
    Toast.warn(e?.message ?? t("toast.failToImportSheet"));
}

Prevention

When it happens

Trigger: Submitting the import-sheet panel with a playlist URL/code that the plugin's `importMusicSheet` resolves to null/undefined/[] — unsupported playlist host, private/deleted playlist, empty playlist, or internal plugin failure that it swallows and returns empty.

Common situations: Pasting a playlist link from a service the plugin doesn't cover; the playlist is private or requires login (expired cookies in plugin user variables); platform API changes breaking the plugin's sheet parser; network timeouts leading the plugin to return an empty array.

Related errors


AI-assisted analysis of maotoumao/MusicFree@d118b18b3d (2026-08-30). Data as JSON: /api/errors/2aae72b9fddf89c0. Report an issue: GitHub.