fix(performance): 메타 연결 테스트 진단이 잘리던 문제

- 비밀값 가림(redact_text)의 기본 300자 한도에서 긴 메타 원문·안내 뒤의 [진단]이 "[진…"으로 잘렸다.
- 연결 테스트 문구를 [진단] 먼저 + 메타 원문(긴 안내 주소 제거) 뒤로 바꾸고,
  광고 연동 오류 문구 한도를 ad_sync.AD_MESSAGE_MAX(1200자)로.
- 테스트: 설정 연결 테스트 경로(AdSyncService)에서 진단 전체·순서·주소 제거·토큰 미포함 확인.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-16 13:26:49 +09:00
parent dc54553d2f
commit 8a597007cb
4 changed files with 37 additions and 4 deletions
@@ -304,3 +304,29 @@ def test_diag_hint_only_outside_connection_test(monkeypatch):
assert ma._DIAG_HINT in str(info.value) and "[진단]" not in str(info.value)
msg = _diag(monkeypatch, debug=_debug(["ads_read"]), adaccounts=ALL_VISIBLE)
assert ma._DIAG_HINT not in msg
def test_connection_test_shows_full_diagnosis_first(monkeypatch):
"""설정 [연결 테스트](AdSyncService) 문구 — 진단이 맨 앞, 잘리지 않음, 메타 원문의 긴 주소는 뺌(2026-10-16 "[진…" 잘림)."""
long_denied = {"error": {"code": 200, "message": "(#200) Ad account owner has NOT grant ads_management or ads_read permission, "
"refer to https://developers.facebook.com/docs/marketing-api/get-started/authorization/"
"#permissions-and-features for details"}}
def handler(req):
if req.url.path.endswith("/debug_token"):
return httpx.Response(200, json=_debug(["ads_read"]))
if req.url.path.endswith("/me/adaccounts"):
return httpx.Response(200, json={"data": []})
return httpx.Response(400, json=long_denied)
_install(monkeypatch, handler)
store = FakeStore()
svc = ad_sync.AdSyncService(store, CredentialService(None, lambda: None))
svc._ctx = lambda code, values=None, user="", cleared=None: _ctx(account_ids="1111111111,2222222222")
res = svc.test_connection("meta")
msg = res["message"]
assert not res["ok"] and res["status"] == "auth_failed"
assert msg.startswith("[진단]") and not msg.endswith("…") and len(msg) > 300 # 예전 300자 한도면 잘렸을 길이
assert "배정되지 않은 계정: act_1111111111, act_2222222222" in msg and "자산 할당" in msg
assert "(메타 원문: 메타 API 오류(200): (#200) Ad account owner has NOT grant" in msg
assert "https://" not in msg and ma._DIAG_HINT not in msg and TOKEN not in msg