{"record":{"id":"149671ee083dea57","repo":"jackwener/OpenCLI","slug":"coursefilter","errorCode":null,"errorMessage":"未找到匹配「${courseFilter}」的课程","messagePattern":"未找到匹配「(.+?)」的课程","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clis/chaoxing/assignments.js","lineNumber":36,"sourceCode":"            help: '按状态过滤',\n        },\n        { name: 'limit', type: 'int', default: 20, help: '最大返回数量' },\n        { name: 'timeout', type: 'int', required: false, default: 90, help: 'Max seconds for the overall command (default: 90)' },\n    ],\n    columns: ['rank', 'course', 'title', 'deadline', 'status', 'score'],\n    func: async (page, kwargs) => {\n        const { course: courseFilter, status: statusFilter = 'all', limit = 20 } = kwargs;\n        // 1. Establish session\n        await initSession(page);\n        // 2. Get courses\n        const courses = await getCourses(page);\n        if (!courses.length)\n            throw new AuthRequiredError('mooc2-ans.chaoxing.com', '未获取到课程列表');\n        const filtered = courseFilter\n            ? courses.filter(c => c.title.includes(courseFilter))\n            : courses;\n        if (courseFilter && !filtered.length) {\n            throw new Error(`未找到匹配「${courseFilter}」的课程`);\n        }\n        // 3. Per-course: enter → click 作业 tab → navigate to iframe → parse\n        const allRows = [];\n        for (const c of filtered) {\n            try {\n                await enterCourse(page, c);\n                const iframeUrl = await getTabIframeUrl(page, '作业');\n                if (!iframeUrl)\n                    continue;\n                await page.goto(iframeUrl);\n                await page.wait(2);\n                const rows = await parseAssignmentsFromDom(page, c.title);\n                allRows.push(...rows);\n            }\n            catch {\n                // Single course failure: skip, continue\n            }\n            if (filtered.length > 1)","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chaoxing/assignments.js#L18-L54","documentation":"After filtering the course list by a courseFilter substring on c.title, if no course title matches, the library throws a plain Error with the filter in the message. This is a user-input mismatch, not an auth problem — the session worked and courses were fetched, but none contained the given string.","triggerScenarios":"Running assignments with --course/课程名 substring that doesn't exactly match any course title (typos, extra spaces, abbreviated names, semester-suffixed titles).","commonSituations":"Typing a shortened course name when the title contains extra terms; course renamed for the new semester; full-width vs half-width characters in Chinese titles.","solutions":["Run assignments without the course filter to list exact available titles, then copy one verbatim","Check for whitespace/full-width character differences between your filter and the real title","Use a shorter, unique substring of the title instead of the full name","Adjust the filter to match the current semester's course name"],"exampleFix":"// before\nawait runAssignments({ course: '高等数学' });\n// after\nconst courses = await listCourses(page); // inspect exact titles first\nawait runAssignments({ course: courses.find(c => c.title.includes('高等数学')).title.slice(0, 6) });","handlingStrategy":"validation","validationCode":"const courses = await listCourses(page);\nconst match = courses.find(c => c.title.includes(courseFilter));\nif (!match) throw new Error(`Available: ${courses.map(c => c.title).join(', ')}`);","typeGuard":"null","tryCatchPattern":"try { await assignments(page, { course: courseFilter }); }\ncatch (e) { if (e.message.includes('未找到匹配')) { console.error('Course not found; run without --course to list titles'); return listCourses(page); } throw e; }","preventionTips":["List courses first and copy titles verbatim","Use short unique substrings instead of full titles","Watch for full-width/half-width character mismatches in Chinese titles","Re-list courses each semester since titles change"],"tags":["chaoxing","filter","no-match","user-input"],"backgroundTag":"no-matching-results","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}