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 top-tracks route (deprecated) when config.lastfm.api_key is missing. Same guard as the other Last.fm routes; the route calls either chart.gettoptracks or geo.gettoptracks depending on whether a :country param is present, both requiring the key.

Source

Thrown at lib/routes-deprecated/lastfm/top.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 country = ctx.params.country;
    const api_key = config.lastfm.api_key;

    const response = await got(`http://ws.audioscrobbler.com/2.0/?method=${country ? 'geo.gettoptracks' : 'chart.gettoptracks'}${country ? '&country=' + country : ''}&api_key=${api_key}&format=json`);
    const data = response.data;
    const list = data.tracks.track;

    ctx.state.data = {
        title: `Top Tracks${country ? ' in ' + data.tracks['@attr'].country : ''} - Last.fm`,
        link: 'https://www.last.fm/charts#top-tracks',
        item: list.map((item) => ({
            title: `${item.name} - ${item.artist.name}`,
            author: item.artist.name,
            description: `<img src="${item.image.at(-1)['#text']}" />`,
            pubDate: new Date(),
            link: item.url,

View on GitHub (pinned to bed535e087)

Solutions

  1. Set LASTFM_API_KEY and restart RSSHub.
  2. Confirm the key works by calling http://ws.audioscrobbler.com/2.0/?method=chart.gettoptracks&api_key=<key>&format=json directly.
  3. Apply the same key to all three Last.fm routes (loved, recent, top).

Example fix

// env
// before
# LASTFM_API_KEY not set
// after
LASTFM_API_KEY=<your_key>
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.LASTFM_API_KEY) {
  throw new Error('LASTFM_API_KEY required for top-tracks (with or without country)');
}

Type guard

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

Try / catch

try { await rsshub('/lastfm/top' + (country ? '/' + country : '')); }
catch (e) {
  if (/disabled due to the lack/.test(e.message)) return configureKey();
  throw e;
}

Prevention

When it happens

Trigger: Request to the top-tracks route (with or without country) while LASTFM_API_KEY is unset; guard throws before the audioscrobbler call.

Common situations: Same as sibling Last.fm routes: unconfigured deployment, env var not propagated, or config block absent. Because this route optionally takes a country param, callers sometimes assume no key is needed — it is always needed.

Related errors


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