이 페이지는 기계 번역되었습니다. 영어 버전이 원본이며 더 정확하거나 최신일 수 있습니다. 영어로 보기

커서 불일치

CURSOR_MISMATCH는 HTTP 400과 함께 옵니다. 커서는 유효하지만 요청이 커서를 만든 검색이 아닙니다. 정렬 순서나 필터가 바뀌었습니다.


의미

커서는 하나의 검색에 속합니다. API는 정렬 순서와 필터의 지문을 기억합니다. 다음 페이지에서 이를 요청과 비교합니다. 다르면 커서로 그 검색을 이어 갈 수 없으므로 API는 이 오류로 응답합니다.

페이지 사이에는 cursor, limit, include만 바꿀 수 있습니다. 나머지는 모두 첫 페이지와 똑같이 다시 보내야 합니다.

응답 예시

첫 페이지는 "query": "ticker:NVDA"로 요청했습니다. 두 번째 페이지는 그 커서를 다른 쿼리와 함께 씁니다:

cURL

curl -X POST 'https://api.finlight.me/v3/articles/search' \
  -H 'Content-Type: application/json' \
  -H 'X-API-KEY: YOUR_API_KEY' \
  -H 'X-Request-Id: req-123' \
  -d '{ "query": "ticker:AMD", "limit": 1, "cursor": "eyJ2IjoxLCJr..." }'

Response (400): filters changed

{
  "type": "https://docs.finlight.me/errors/cursor-mismatch",
  "title": "Cursor mismatch",
  "status": 400,
  "detail": "The cursor was issued for a different set of filters. Start a new search without a cursor.",
  "code": "CURSOR_MISMATCH",
  "requestId": "req-123",
  "errors": [
    { "field": "cursor", "issue": "The cursor was issued for a different set of filters. Start a new search without a cursor." }
  ]
}

정렬 순서가 바뀌었으면 detail에 두 순서가 모두 나옵니다:

Response (400): sort order changed

{
  "type": "https://docs.finlight.me/errors/cursor-mismatch",
  "title": "Cursor mismatch",
  "status": 400,
  "detail": "The cursor was issued for sort order 'publishedAt:desc', the request asks for 'publishedAt:asc'.",
  "code": "CURSOR_MISMATCH",
  "requestId": "req-123",
  "errors": [
    { "field": "cursor", "issue": "The cursor was issued for sort order 'publishedAt:desc', the request asks for 'publishedAt:asc'." }
  ]
}

흔한 원인

  • 이후 페이지에서 다른 orderBy나 order.
  • 바뀐 필터, 예: 다른 query, tickers, sources.
  • 이후 페이지에 to 추가. 흔한 실수는 페이지마다 to를 현재 시각으로 설정하는 것입니다. to 없는 첫 페이지와 to가 있는 두 번째 페이지는 서로 다른 검색입니다. to를 빼거나 첫 페이지의 정확한 값을 유지하세요.
  • 기본값 추가. 없는 필드는 기본값과 같지 않습니다. 첫 페이지에 languages가 없었다면 ["en"]이 기본값이더라도 두 번째 페이지의 "languages": ["en"]은 다른 검색입니다. orderBy와 order만 기본값을 채워 비교하므로 2페이지에 "order": "desc"를 추가하는 것은 괜찮습니다.
  • 값의 다른 표기. 값은 정규화되지 않습니다. ["EN"]은 ["en"]이 아닙니다.

목록 안 값의 순서와 반복된 값은 상관없습니다. ["de", "en"]과 ["en", "de"]는 같은 필터입니다.

해결 방법

  1. 첫 페이지의 요청 본문을 저장합니다.
  2. 이후 모든 페이지에서 그 본문을 다시 보내고 cursor, limit, include만 추가하거나 바꿉니다.
  3. 정말로 다른 필터나 다른 순서를 원한다면 cursor 없이 새 검색을 시작합니다.

클라이언트 라이브러리가 대신 처리합니다. searchAll(Python: search_all)은 호출할 때 요청을 고정하고 이후 페이지에는 커서만 추가합니다. 페이지네이션을 참조하세요.

재시도

재시도하지 마세요. 같은 요청은 다시 실패합니다. 클라이언트 라이브러리는 이를 재시도하지 않으며, searchAll은 이 오류로 멈춥니다.

SDK에서

언어오류
TypeScript, Python, RubyCursorMismatchError
.NET, Java, PHPCursorMismatchException
GoAPIKind == finlight.APIKindCursorMismatch인 *finlight.APIError
Rustapi_kind() == ApiErrorKind::CursorMismatch인 Error::Api

라이브러리에 페이지 넘기기 맡기기

for await (const article of client.articles.searchAll({ query: 'ticker:NVDA', limit: 100 }, { maxPages: 5 })) {
  console.log(article.id, article.title)
}