Repository navigation
Conversation
The Naver shopping/news routes forwarded the upstream HTTP status verbatim, so an upstream 404 (`errorCode: SE05`, missing Shopping search permission on the production app) reached clients as if `/v1/naver-shopping/search` did not exist, and an upstream 401 looked like a proxy-level auth rejection. `createUpstreamHttpError` (new `src/naver-upstream-error.js`) now classifies every non-OK Naver response: 429 stays 429 with `upstream_rate_limited` and a passthrough `Retry-After`, everything else becomes 502 `upstream_error`. The real status and a body snippet stay in `upstream.status_code` / `upstream.body_snippet`, plus `upstream.error_code` parsed from the Naver JSON body (SE05/024/010) and `upstream.retry_after`. Proxy-side validation still answers 400. The no-key BFF fallback uses the same helper for consistency. Refs #717
This was referenced Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
배경 (Refs #717 item 2)
/v1/naver-shopping/search는 upstream 이 4xx 를 주면 그 상태 코드를 그대로 클라이언트에 전달했습니다. 그래서 프로덕션 앱에 Shopping search API 권한이 없어 네이버가 404SE05를 주면, 클라이언트/스킬은 "프록시 라우트가 없다"로 해석하게 됩니다.배포 중인 프록시(현재 main 기준)에서 재현:
packages/k-skill-proxy/src/naver-shopping.js의fetchNaverShoppingOpenApiSearch가error.statusCode = response.status >= 400 && response.status < 500 ? response.status : 502로 upstream 4xx 를 그대로 통과시켰고(수정 전 753-756행),src/server.js의 라우트 catch 가 그 값을reply.code(...)로 사용했습니다(수정 전 5600행 부근).naver-news.js(수정 전 226-229행) / 그 라우트도 동일했습니다.upstream_error로 정규화하고, 진단 정보(upstream 상태/본문 스니펫)와 네이버 오류 코드는upstream블록에 보존한다. 429 는 429 를 유지한다.변경
src/naver-upstream-error.js(신규):createUpstreamHttpError({ apiLabel, status, body, headers })code: "upstream_rate_limited", 429 +Retry-After파싱(숫자 초만, HTTP-date 는 무시)code: "upstream_error", 502upstreamStatusCode,upstreamBodySnippet(200자),upstreamErrorCode(JSON 본문의errorCode/error_code, 예:SE05/024/010) 보존src/naver-shopping.js: 공식 Search API 경로 + no-key BFF fallback 경로 모두 이 헬퍼 사용 (BFF 는 이미 502 였지만 코드 중복을 제거하고 429/오류코드 처리를 동일하게 맞춤). fallback 추가 없음(BFF 는 418 을 주므로 도움되지 않음).src/naver-news.js: 동일 헬퍼 사용.src/server.js: 두 라우트의 catch 에서buildUpstreamErrorDetails(error)로upstream.status_code/body_snippet(+ 있으면error_code,retry_after) 를 만들고,retry_after가 있으면retry-after응답 헤더도 내려줍니다. 프록시 자체 검증 실패는 계속 400.naver-news-search/instruction.md실패 모드 목록이 기존 401/429 passthrough 를 문서화하고 있어 새 규약으로 갱신(generate:skill-stubs,sync:cli-skills실행, patch changeset 추가).docs/features/naver-news-search.md와 CLI 스냅샷도 함께 갱신.naver-shopping-search/instruction.md는 passthrough 를 문서화하지 않아 변경하지 않았습니다.테스트 (mocked fetch, 실패→통과 확인)
수정 전
node --test test/naver-shopping.test.js test/naver-news.test.js에서 6개 실패:수정 후 전부 통과. 추가로:
404+errorCode: SE05→ 502upstream_error,upstream.status_code: 404,upstream.error_code: "SE05"401+errorCode: 024→ 502 (naver-news는 실패 응답 미캐시 검증 유지)429+Retry-After: 60→ 429upstream_rate_limited,upstream.retry_after: 60,retry-after헤더upstream_error,upstream.status_code: 418로컬 검증:
cd packages/k-skill-proxy && node --test→ 493 tests / 491 pass / 0 fail / 2 skipped,npm run lint통과.남은 것 (이 PR 범위 밖, ops)
프로덕션 네이버 앱에 Shopping search API 권한이 없어
SE05자체는 계속 발생합니다. 이 PR 은 그 사실이 404 대신 진단 가능한 502 +upstream.error_code: SE05로 보이게만 합니다. key 없는 fallback(ns-portal.shopping.naver.com)은 418access temporarily restricted를 반환해 대체 경로가 될 수 없습니다.