Skip to content

fix(express-bus-booking): KOBUS 주석 템플릿을 운행편에서 제외 (#698) - #702

Merged
vkehfdl1 merged 1 commit into
devfrom
fix/698-kobus-comment-template-schedules
Oct 6, 2026
Merged

vkehfdl1 merged 1 commit into
devfrom
fix/698-kobus-comment-template-schedules

Conversation

@vkehfdl1

@vkehfdl1 vkehfdl1 commented Oct 6, 2026

Copy link
Copy Markdown
Member

Fixes #698

원인

KOBUS mrs/alcnSrch.do 응답에는 실제 onclick="fnSatsChc('...')" 호출과 HTML 주석 템플릿 <!-- fnSatsChc(deprTime,alcnDeprTime,...) -->가 함께 들어 있습니다. 기존 파서는 원본 HTML 전체에 대해 fnSatsChc\((.*?)\)를 실행해 주석 템플릿까지 운행편으로 만들었고, raw_args=[]·departure_time=null인 가짜 항목이 섞여 편수가 2배가 되었습니다. 그 항목을 선택하면 seat_stage_fields()의 a[1] 접근에서 IndexError가 났습니다.

변경

  • HTML_COMMENT_RE로 주석을 먼저 제거한 뒤 호출을 파싱합니다.
  • FN_SATS_RE가 ( 바로 뒤 따옴표를 요구하도록 해 템플릿(deprTime,...)과 함수 정의를 매칭에서 제외합니다.
  • 필수 인자 수 MIN_SATS_ARGS=14(seat_stage_fields()가 읽는 최대 인덱스 13 + 1) 미만 항목은 결과에서 버립니다.
  • 파싱 로직을 parse_schedules()로 분리해 네트워크 없이 테스트합니다.
  • --select-index가 범위를 벗어나면 IndexError 대신 명시적 SystemExit을 냅니다.

검증

  • express-bus-booking/tests/test_kobus_express_booking.py 신규: 주석/템플릿 제외, 주석 처리된 실제 호출 제외, 불완전 인자 드롭, index 연속성, select-index 범위 오류(11 tests).
  • 실 KOBUS 조회 QA: --depart-code 021 --arrive-code 500 --date 20261010 → count=114(기존 228), departure_time=null 항목 없음.
  • --select-index 200 --hold-first-seat → --select-index 200 is out of range: parsed 114 schedule(s) (valid range 1-114).
  • 조회만 수행했고 좌석 선점·결제·예약 제출은 하지 않았습니다.

체크

  • npm run lint 통과, npm run sync:cli-skills 반영.

KOBUS 응답은 실제 fnSatsChc('...') 호출과 HTML 주석 프로토타입
fnSatsChc(deprTime,...)을 함께 담는다. 파서가 원본 전체를 대상으로
정규식을 돌려 주석 템플릿까지 운행편으로 만들었고, 그 결과 편수가
2배가 되고 raw_args=[]·departure_time=null 항목이 생겨 선점 단계에서
IndexError가 났다.

주석/템플릿을 먼저 제거하고, 여는 따옴표가 있는 실제 호출만 매칭하며,
필수 인자 수(14) 미만은 버린다. --select-index 범위 검증도 추가한다.
@vkehfdl1
vkehfdl1 merged commit 13875d3 into dev Oct 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant