{"record":{"id":"f6819c8bebe60d3a","repo":"yikart/AiToEarn","slug":"channelid-id-mine","errorCode":null,"errorMessage":"只能选择一个参数: channelId, id, mine","messagePattern":"只能选择一个参数: channelId, id, mine","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"project/aitoearn-electron/server/src/modules/plat/youtube/youtube.controller.ts","lineNumber":188,"sourceCode":"  }\n\n  @ApiOperation({ summary: '获取频道板块列表' })\n  @Get('channels/sections/list')\n  async getChannelSectionsList(\n    @GetToken() token: TokenInfo,\n    @Query('accountId') accountId: string,\n    @Query('channelId') channelId?: string,\n    @Query('id') id?: string,\n    @Query('maxResults') maxResults?: string,\n    @Query('mine') mine?: boolean,\n    @Query('pageToken') pageToken?: string,\n    ) {\n    // 校验确保只有一个参数传递\n    const params = [channelId, id, mine];\n    const nonEmptyParams = params.filter(param => param !== undefined && param !== null && param !== '');\n\n    if (nonEmptyParams.length > 1) {\n      throw new BadRequestException('只能选择一个参数: channelId, id, mine');\n    }\n    const accessToken = await this.youtubeAuthService.getUserAccessToken(accountId);\n    return this.youtubeService.getChannelSectionsList(accessToken, channelId, id, mine, maxResults, pageToken);\n  }\n\n  @ApiOperation({ summary: '创建频道板块' })\n  @Post('channels/sections/insert')\n  async channelsSectionsInsert(\n    @GetToken() token: TokenInfo,\n    @Body('accountId') accountId: string,\n    @Body('snippet') snippet?: Record<string, any>,\n    @Body('contentDetails') contentDetails?: Record<string, any>,\n  ) {\n    const accessToken = await this.youtubeAuthService.getUserAccessToken(accountId);\n    return this.youtubeService.insertChannelSection(accessToken, snippet, contentDetails);\n  }\n\n  @ApiOperation({ summary: '更新频道版块' })","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-electron/server/src/modules/plat/youtube/youtube.controller.ts#L170-L206","documentation":"channelSections.list supports filtering by exactly one of channelId, id, or mine. The controller enforces this by counting non-empty parameters and throwing BadRequestException when more than one is supplied.","triggerScenarios":"Requesting GET channelSections/list with both channelId=UC... and mine=true, or id=SEC... together with channelId.","commonSituations":"Persisted query state accumulating filters across user interactions; automated callers always appending mine=true as default; API gateway injecting default params.","solutions":["Pass only one filter parameter per call","Remove default mine/channelId values from client request builders when another filter is used","Use id alone (with maxResults/pageToken for pagination) when fetching specific sections"],"exampleFix":"// before\nreturn this.youtubeService.getChannelSectionsList(accessToken, channelId, id, mine, maxResults, pageToken); // caller sent channelId AND mine\n// after\n// caller sends only one, e.g.\nGET /api/plat/youtube/channelSections/list?accountId=acc1&channelId=UCxxx&maxResults=10","handlingStrategy":"validation","validationCode":"const filters = { channelId, id, mine };\nconst count = Object.values(filters).filter(v => v !== undefined && v !== null && v !== '').length;\nif (count > 1) throw new Error('Provide at most one of channelId, id, mine');","typeGuard":null,"tryCatchPattern":"try {\n  const sections = await api.get('/plat/youtube/channelSections/list', { params });\n} catch (e) {\n  if (e.response?.status === 400 && String(e.response.data?.message).includes('只能选择一个参数')) {\n    params = prioritizeFilter(params, ['id', 'channelId', 'mine']);\n  }\n}","preventionTips":["Send id for specific sections; channelId for a channel's sections; mine only for the authorized user","Strip defaults from request builders when explicit filters are present","Add a client-side single-filter assertion 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"}