Skip to content

fix(reverse_sync): improved MDX trailing whitespace 입력값 검증 추가#908

Merged
jk-kim0 merged 2 commits intomainfrom
jk/fix-reverse-sync-verifier-trailing-ws
Mar 12, 2026
Merged

fix(reverse_sync): improved MDX trailing whitespace 입력값 검증 추가#908
jk-kim0 merged 2 commits intomainfrom
jk/fix-reverse-sync-verifier-trailing-ws

Conversation

@jk-kim0
Copy link
Contributor

@jk-kim0 jk-kim0 commented Mar 11, 2026

Description

reverse-sync verify 실행 시 improved MDX에 trailing whitespace가 있으면 즉시 입력값 오류로 실패하도록 검증 단계를 추가합니다.

trailing whitespace는 reverse-sync 코드의 버그가 아니라 입력값(improved MDX)의 오류이므로, 진단 가능한 에러로 처리합니다.

변경 내용

bin/reverse_sync_cli.py

  • run_verify()에서 improved MDX를 읽은 직후 trailing whitespace 검증
  • 발견 시 ValueError raise → 줄 번호 + repr(line) 형태로 위치 출력

tests/run-tests.sh

  • --xhtml--page-dir 인자 수정 (CLI 변경 반영)
  • CLI가 조기 종료해 result.yaml이 없을 때의 처리 수정
    • result.yaml cp에 2>/dev/null || true 추가
    • status 변수 기본값을 "error"로 설정하고, result.yaml이 있을 때만 읽도록 변경

에러 출력 예시

Error: Trailing whitespace found in improved MDX (tests/reverse-sync/543948978/improved.mdx).
This is an input error, not a reverse-sync bug. Please remove trailing whitespace before running reverse-sync.
Locations:
  line 22: '* [ **General** ](company-management/general) **:** 쿼리파이의 기본 시스템 설정을 적용하는 메뉴입니다. '
  line 23: '* [ **Security** ](company-management/security) : 쿼리파이의 보안 설정을 적용하는 메뉴입니다. '

Added/updated tests?

  • Yes: run-tests.sh 수정으로 trailing whitespace 케이스의 에러 출력이 깔끔하게 표시됨

🤖 Generated with Claude Code

@vercel
Copy link

vercel bot commented Mar 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
querypie-docs Ready Ready Preview, Comment Mar 12, 2026 10:16am

Request Review

@jk-kim0 jk-kim0 changed the title fix(confluence-mdx): roundtrip_verifier trailing whitespace 정규화를 lenient 모드 전용으로 이동 fix(reverse_sync): roundtrip_verifier trailing whitespace 정규화를 lenient 모드 전용으로 이동 Mar 11, 2026
@jk-kim0 jk-kim0 self-assigned this Mar 11, 2026
@jk-kim0 jk-kim0 force-pushed the jk/fix-reverse-sync-verifier-trailing-ws branch from dc84e27 to fec2457 Compare March 11, 2026 16:45
@jk-kim0 jk-kim0 force-pushed the jk/fix-reverse-sync-verifier-h1-table branch from 9f5c927 to 9a61179 Compare March 11, 2026 16:45
jk-kim0 added a commit that referenced this pull request Mar 12, 2026
## Description

`verify_roundtrip`의 strict 모드에서도 forward converter의 체계적 출력 특성에 의한 차이를
정규화하여 false negative를 줄입니다.

**추가된 최소 정규화 (strict/lenient 공통 적용):**

- `_normalize_consecutive_spaces_in_text`: 코드 블록 외 영역에서 2개 이상 연속 공백을 단일
공백으로 정규화
- 배경: `improved.mdx`에 `**bold** :` 형태의 이중 공백이 있어도 forward converter는 단일
공백으로 출력
- `_normalize_br_space`: `<br/>` 앞의 공백 제거
  - 배경: forward converter가 `' '.join(li_itself)`로 `<br/>` 앞에 공백을 추가

**변경하지 않은 것:**
- `_normalize_trailing_ws`는 최소 정규화에 포함하지 않음 (strict 모드의 trailing
whitespace 검사 보존)

## Added/updated tests?
- [x] Yes

`TestNormalizeConsecutiveSpaces` (5개), `TestNormalizeBrSpace` (5개), 통합
테스트 3개 추가 — 총 22개 테스트 통과

## Stacked PRs

이 PR은 stacked PR 시리즈의 일부입니다:
- #906 (이 PR): 최소 정규화 (`_apply_minimal_normalizations`)
- #907: `_normalize_table_cell_padding` 추가
- #908: `_normalize_trailing_ws` lenient 모드 이동

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@jk-kim0 jk-kim0 force-pushed the jk/fix-reverse-sync-verifier-h1-table branch 4 times, most recently from 5e47e47 to 94c1b91 Compare March 12, 2026 05:30
Base automatically changed from jk/fix-reverse-sync-verifier-h1-table to main March 12, 2026 05:36
@jk-kim0 jk-kim0 force-pushed the jk/fix-reverse-sync-verifier-trailing-ws branch from fec2457 to 21c5068 Compare March 12, 2026 05:40
@jk-kim0 jk-kim0 force-pushed the jk/fix-reverse-sync-verifier-trailing-ws branch from 21c5068 to 9ebe42a Compare March 12, 2026 06:39
@jk-kim0 jk-kim0 marked this pull request as draft March 12, 2026 06:41
@jk-kim0 jk-kim0 force-pushed the jk/fix-reverse-sync-verifier-trailing-ws branch from 9ebe42a to d9f7856 Compare March 12, 2026 07:14
@jk-kim0 jk-kim0 changed the title fix(reverse_sync): roundtrip_verifier trailing whitespace 정규화를 lenient 모드 전용으로 이동 [디버깅용] fix(reverse_sync): roundtrip_verifier trailing whitespace 정규화를 lenient 모드 전용으로 이동 Mar 12, 2026
@jk-kim0 jk-kim0 changed the base branch from main to jk/feat-sidecar-type-based-core March 12, 2026 07:15
@jk-kim0 jk-kim0 force-pushed the jk/fix-reverse-sync-verifier-trailing-ws branch from 2c27048 to 70e4fd6 Compare March 12, 2026 08:13
@jk-kim0 jk-kim0 changed the title [디버깅용] fix(reverse_sync): roundtrip_verifier trailing whitespace 정규화를 lenient 모드 전용으로 이동 fix(reverse_sync): improved MDX trailing whitespace 입력값 검증 추가 Mar 12, 2026
@jk-kim0 jk-kim0 marked this pull request as ready for review March 12, 2026 08:14
@jk-kim0 jk-kim0 force-pushed the jk/fix-reverse-sync-verifier-trailing-ws branch 2 times, most recently from ab5797d to 9746d2c Compare March 12, 2026 08:15
@jk-kim0 jk-kim0 force-pushed the jk/fix-reverse-sync-verifier-trailing-ws branch from 9746d2c to 95bdde5 Compare March 12, 2026 08:16
@jk-kim0 jk-kim0 changed the base branch from jk/feat-sidecar-type-based-core to main March 12, 2026 08:16
@jk-kim0 jk-kim0 force-pushed the jk/fix-reverse-sync-verifier-trailing-ws branch from 95bdde5 to 4f5fc22 Compare March 12, 2026 09:02
@jk-kim0 jk-kim0 force-pushed the jk/fix-reverse-sync-verifier-trailing-ws branch from 4f5fc22 to 2e1d360 Compare March 12, 2026 09:12
reverse-sync verify 실행 시 improved MDX에 trailing whitespace가 있으면
즉시 입력값 오류로 실패하도록 검증 단계를 추가합니다.

- run_verify()에서 improved MDX를 읽은 직후 trailing whitespace 검사
- 발견 시 에러 메시지와 함께 파일명, 줄 번호, 해당 줄 내용을 출력
- ValueError를 raise하여 main()의 기존 에러 핸들러가 처리
- run-tests.sh: result.yaml이 없을 때 cp/status 오류 없이 처리

trailing whitespace는 reverse-sync 코드의 버그가 아니라
입력값(improved MDX)의 오류이므로, 진단 가능한 에러로 처리합니다.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
trailing whitespace 제거 후 CI 결과와 다시 맞춥니다.

- expected_status: fail → pass (verify가 pass로 전환된 케이스 8건):
  543948978, 544376265, 544378513, 544383693, 565575990, 568852692, 920944732, 1177321474
- expected_status: pass → fail (verify가 여전히 fail인 케이스 8건):
  543981760, 544376394, 544382364, 619381289, 798064641, 954172219, 1297383451, 1907294209

로컬 검증: reverse-sync tests → 42/42 pass

Co-Authored-By: Atlas <atlas@jk.agent>
@jk-kim0 jk-kim0 merged commit 9ff6040 into main Mar 12, 2026
7 checks passed
@jk-kim0 jk-kim0 deleted the jk/fix-reverse-sync-verifier-trailing-ws branch March 12, 2026 10:30
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