{"record":{"id":"d09d077e3050eae6","repo":"yikart/AiToEarn","slug":"regioncode-id","errorCode":null,"errorMessage":"只能选择一个参数: regionCode, id","messagePattern":"只能选择一个参数: regionCode, id","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"project/aitoearn-electron/server/src/modules/plat/youtube/youtube.controller.ts","lineNumber":344,"sourceCode":"  ) {\n    const accessToken = await this.youtubeAuthService.getUserAccessToken(accountId);\n    return this.youtubeService.insertCommentThreads(accessToken, snippet);\n  }\n\n  @ApiOperation({ summary: '获取视频类别列表' })\n  @Get('video/categories/list')\n  async getVideoCategoriesList(\n    @GetToken() token: TokenInfo,\n    @Query('accountId') accountId: string,\n    @Query('regionCode') regionCode?: string,\n    @Query('id') id?: string\n    ) {\n    // 校验确保只有一个参数传递\n    const params = [regionCode, id];\n    const nonEmptyParams = params.filter(param => param !== undefined && param !== null && param !== '');\n\n    if (nonEmptyParams.length > 1) {\n      throw new BadRequestException('只能选择一个参数: regionCode, id');\n    }\n    const accessToken = await this.youtubeAuthService.getUserAccessToken(accountId);\n    return this.youtubeService.getVideoCategoriesList(accessToken, id, regionCode);\n  }\n\n  @ApiOperation({ summary: '获取视频列表' })\n  @Get('videos/list')\n  async getVideosList(\n    @GetToken() token: TokenInfo,\n    @Query('accountId') accountId: string,\n    @Query('id') id?: string,\n    @Query('myRating') myRating?: string,\n    @Query('maxResults') maxResults?: string,\n    @Query('pageToken') pageToken?: string,\n    ) {\n    // 校验确保只有一个参数传递\n    const params = [id, myRating];\n    const nonEmptyParams = params.filter(param => param !== undefined && param !== null && param !== '');","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-electron/server/src/modules/plat/youtube/youtube.controller.ts#L326-L362","documentation":"videoCategories.list accepts either regionCode (categories for a region) or a specific id (a single category). The controller enforces at most one of the two and throws BadRequestException otherwise.","triggerScenarios":"GET videoCategories/list called with both regionCode=US and id=1 (or id=20).","commonSituations":"Client merges a region default with a specific category id; spec exploration where both were appended to see behavior; template-based URL builders concatenating all provided options.","solutions":["Call once with regionCode to list all categories for a region, or once with id to fetch one category — never both","If a category id is known, regionCode is unnecessary; drop it","Validate query composition client-side before sending"],"exampleFix":"// before\nGET /api/plat/youtube/videoCategories/list?accountId=a&regionCode=US&id=20\n// after\nGET /api/plat/youtube/videoCategories/list?accountId=a&regionCode=US","handlingStrategy":"validation","validationCode":"const filters = { regionCode, id };\nconst count = Object.values(filters).filter(v => v !== undefined && v !== null && v !== '').length;\nif (count > 1) throw new Error('Provide either regionCode or id, not both');","typeGuard":null,"tryCatchPattern":"try {\n  const cats = await api.get('/plat/youtube/videoCategories/list', { params });\n} catch (e) {\n  if (e.response?.status === 400 && String(e.response.data?.message).includes('只能选择一个参数')) {\n    params = params.id ? { id: params.id } : { regionCode: params.regionCode };\n  }\n}","preventionTips":["Use regionCode (e.g. US) to enumerate categories; id to fetch one — pick per use case","Drop regionCode when a specific category id is already known","Validate ISO regionCode format and numeric id before sending"],"tags":["http-400","validation","youtube-api","query-param"],"backgroundTag":"mutually-exclusive-parameters","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}