DIYgod/RSSHub · warning · Error

该用户运动日记为空

Error message

该用户运动日记为空

What it means

Thrown by the Keep (fitness app) route when the user-profile API returns a non-empty response but response.data.entries is an empty array. This means the API call succeeded but the user has no workout diary entries to surface. The Chinese message translates to 'this user's workout diary is empty'.

Source

Thrown at lib/routes/keep/user.tsx:40

        },
    ],
    name: '运动日记',
    maintainers: ['Dectinc', 'DIYgod'],
    handler,
};

async function handler(ctx) {
    const id = ctx.req.param('id');

    const response = await ofetch(`https://api.gotokeep.com/social/v3/people/${id}/home`, {
        headers: {
            Referer: `https://show.gotokeep.com/users/${id}`,
        },
    });

    // check user have post or not
    if (response.data.entries.length === 0) {
        throw new Error('该用户运动日记为空');
    }

    const items = response.data.entries.flatMap((entry) =>
        entry.entries.map((item) => {
            let images: string[] = [];
            if (item.images) {
                images = item.meta.picture ? [item.meta.picture, ...item.images] : item.images;
            } else if (item.meta.picture) {
                images = [item.meta.picture];
            }

            const minute = Math.floor(item.meta.secondDuration / 60);
            const second = item.meta.secondDuration - minute * 60;
            return {
                title: item.meta.title.trim(),
                pubDate: item.created,
                link: `https://show.gotokeep.com/entries/${item.id}`,
                author: item.author.username,

View on GitHub (pinned to bed535e087)

Solutions

  1. Verify the user ID by visiting https://show.gotokeep.com/users/{id} in a browser — confirm the profile exists and has public workout entries.
  2. If the user genuinely has no posts, this is expected behavior; consider using the route's allowEmpty option to return an empty feed instead of erroring.
  3. If the API response shape changed, inspect response.data to find the new location of the entries array and update the accessor.
  4. Add a separate check for a non-existent user (e.g. response.data error field) to distinguish 'no posts' from 'bad id'.

Example fix

// before
if (response.data.entries.length === 0) {
    throw new Error('该用户运动日记为空');
}

// after — distinguish invalid user from empty diary
if (!response.data || !response.data.entries) {
    throw new Error(`Invalid Keep user id or API error for ${id}`);
}
if (response.data.entries.length === 0) {
    return { title: `Keep user ${id}`, item: [], allowEmpty: true };
}
Defensive patterns

Strategy: validation

Validate before calling

const response = await ofetch(`https://api.gotokeep.com/social/v3/people/${id}/home`, { headers: { Referer: `...` } });
if (!response?.data || !Array.isArray(response.data.entries)) {
    throw new Error(`Unexpected Keep API response for user ${id}`);
}
if (response.data.entries.length === 0) {
    // genuine empty diary — return empty feed instead of erroring
    return { title: `Keep user ${id}`, item: [], allowEmpty: true };
}

Type guard

function isKeepHomeResponse(r: unknown): r is { data: { entries: Array<{ entries: unknown[] }> } } {
    return typeof r === 'object' && r !== null &&
        'data' in r && Array.isArray((r as any).data?.entries);
}

Prevention

When it happens

Trigger: Calling /keep/user/:id for a user who has not published any workout entries, has set their diary to private (Keep may return empty instead of a permission error), or whose account has been deactivated. Also possible if the id is syntactically valid but does not correspond to any user, in which case Keep returns an empty entries array rather than a 404.

Common situations: A new Keep user who hasn't logged any workouts. A user who deleted all their posts. An incorrect ID that Keep silently resolves to an empty profile. The Keep API changed its response envelope and entries moved to a different field.

Related errors


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