DIYgod/RSSHub · error

Last.fm RSS is disabled due to the lack of <a href="https://

Error message

Last.fm RSS is disabled due to the lack of <a href="https://docs.rsshub.app/deploy/config#route-specific-configurations">relevant config</a>

What it means

Thrown by the Last.fm recent-tracks route (deprecated) under the same missing-config guard as the loved-tracks route: config.lastfm or config.lastfm.api_key absent. The route needs the key to call user.getrecenttracks on the audioscrobbler API.

Source

Thrown at lib/routes-deprecated/lastfm/recent.js:6

const got = require('@/utils/got');
const config = require('@/config').value;

module.exports = async (ctx) => {
    if (!config.lastfm || !config.lastfm.api_key) {
        throw new Error('Last.fm RSS is disabled due to the lack of <a href="https://docs.rsshub.app/deploy/config#route-specific-configurations">relevant config</a>');
    }

    const user = ctx.params.user;
    const api_key = config.lastfm.api_key;

    const response = await got(`http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=${user}&api_key=${api_key}&format=json`);
    const data = response.data;
    const list = data.recenttracks.track;

    ctx.state.data = {
        title: `Recent Tracks by ${data.recenttracks['@attr'].user} - Last.fm`,
        link: `https://www.last.fm/user/${user}/library`,
        item: list.map((item) => ({
            title: `${item.name} - ${item.artist['#text']}`,
            author: item.artist['#text'],
            description: `<img src="${item.image.at(-1)['#text']}" />`,
            pubDate: new Date(item.date.uts * 1000),
            link: item.url,

View on GitHub (pinned to bed535e087)

Solutions

  1. Set LASTFM_API_KEY (create one at https://www.last.fm/api/account/create) and restart RSSHub.
  2. Verify config.lastfm.api_key is non-empty at runtime.
  3. If the key is invalid (not missing), note this guard will NOT catch it — Last.fm returns an error payload downstream instead.

Example fix

// before
config.lastfm = undefined
// after
config.lastfm = { api_key: process.env.LASTFM_API_KEY }
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.LASTFM_API_KEY) {
  throw new Error('Configure LASTFM_API_KEY to use Last.fm recent tracks');
}

Type guard

const hasLastfmConfig = (c: { lastfm?: { api_key?: string } }): boolean =>
  Boolean(c.lastfm?.api_key);

Try / catch

try { await rsshub('/lastfm/recent/' + user); }
catch (e) {
  if (/disabled due to the lack/.test(e.message)) return promptConfig();
  throw e;
}

Prevention

When it happens

Trigger: Any request to the recent-tracks route when LASTFM_API_KEY is unset; the guard throws before the HTTP call.

Common situations: Deployment without LASTFM_API_KEY, key rotated/revoked at Last.fm but not updated in config, or config.lastfm block misnamed.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/77ee8f411833b3e1. Report an issue: GitHub.