{"record":{"id":"2d874109347d8e39","repo":"DIYgod/RSSHub","slug":"invalid-uid-uid-should-start-with-b-ms4wljabaaaa","errorCode":null,"errorMessage":"Invalid UID. UID should start with <b>MS4wLjABAAAA</b>.","messagePattern":"Invalid UID\\. UID should start with <b>MS4wLjABAAAA</b>\\.","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":503,"severity":"error","filePath":"lib/routes/douyin/user.ts","lineNumber":40,"sourceCode":"        supportBT: false,\n        supportPodcast: false,\n        supportScihub: false,\n    },\n    radar: [\n        {\n            source: ['douyin.com/user/:uid'],\n            target: '/user/:uid',\n        },\n    ],\n    name: '博主',\n    maintainers: ['Max-Tortoise', 'Rongronggg9'],\n    handler,\n};\n\nasync function handler(ctx) {\n    const uid = ctx.req.param('uid');\n    if (!uid.startsWith('MS4wLjABAAAA')) {\n        throw new InvalidParameterError('Invalid UID. UID should start with <b>MS4wLjABAAAA</b>.');\n    }\n    const routeParams = Object.fromEntries(new URLSearchParams(ctx.req.param('routeParams')));\n    const embed = fallback(undefined, queryToBoolean(routeParams.embed), false); // embed video\n    const iframe = fallback(undefined, queryToBoolean(routeParams.iframe), false); // embed video in iframe\n    const relay = resolveUrl(routeParams.relay, true, true); // embed video behind a reverse proxy\n\n    const pageUrl = `https://www.douyin.com/user/${uid}`;\n\n    const pageData = (await cache.tryGet(\n        `douyin:user:${uid}`,\n        async () => {\n            let postData;\n            const context = await playwright();\n            const page = await context.newPage();\n            await page.route('**/*', (route) => {\n                const request = route.request();\n                request.resourceType() === 'document' || request.resourceType() === 'script' || request.resourceType() === 'xhr' ? route.continue() : route.abort();\n            });","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/douyin/user.ts#L22-L58","documentation":"Thrown by the Douyin user feed route when the `uid` path parameter does not start with the base64 prefix `MS4wLjABAAAA`. All Douyin `sec_uid` values (the security user ID used in profile URLs) begin with this prefix — it encodes a fixed header in Douyin's protobuf-based ID format. If the uid doesn't match, it's almost certainly the wrong type of identifier (e.g. a short numeric ID, a username, or a malformed value).","triggerScenarios":"User supplies a short numeric user ID instead of the sec_uid; user supplies a Douyin username instead of sec_uid; the uid was truncated or URL-decoded incorrectly (the sec_uid contains characters that may need encoding).","commonSituations":"Developer confuses Douyin's numeric user ID with the sec_uid; the URL was copy-pasted partially; URL encoding of special characters in the sec_uid (it contains hyphens and underscores which are URL-safe, but if %-encoded may not match).","solutions":["Find the correct sec_uid from the user's profile URL: https://www.douyin.com/user/MS4wLjABAAAA... — copy everything after /user/.","Ensure the full sec_uid is included — it is typically 70+ characters long.","Do not use the numeric user ID or the @username — only the sec_uid works."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function isValidDouyinUid(uid: string): boolean {\n    return uid.startsWith('MS4wLjABAAAA');\n}\n\nconst uid = userInput;\nif (!isValidDouyinUid(uid)) {\n    throw new Error(`Invalid UID. Must start with 'MS4wLjABAAAA'. Got: ${uid.substring(0, 20)}...`);\n}","typeGuard":"function isDouyinSecUid(value: string): boolean {\n    return value.startsWith('MS4wLjABAAAA');\n}","tryCatchPattern":"try {\n    const feed = await fetch(`${rsshubUrl}/douyin/user/${uid}`);\n} catch (e) {\n    if (e.message.includes('Invalid UID')) {\n        console.error('Use the sec_uid from the profile URL, not the numeric ID or username.');\n    }\n    throw e;\n}","preventionTips":["Copy the full sec_uid from the profile URL: https://www.douyin.com/user/MS4wLjABAAAA...","Do not use short numeric IDs or @usernames.","Ensure the sec_uid is not truncated — it is typically 70+ characters."],"tags":["douyin","invalid-parameter","uid-validation","base64-prefix"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}