Skip to content

fix(collector): filter non-six-digit symbols before name lookup - #12

Merged
mytrashcan merged 1 commit into
mainfrom
fix/ranking-name-lookup
Jul 31, 2026
Merged

mytrashcan merged 1 commit into
mainfrom
fix/ranking-name-lookup

Conversation

@mytrashcan

Copy link
Copy Markdown
Owner

Summary

Fixes the ranking dashboard showing name: null for some rows (only the stock code visible).

Root cause: Toss ranking responses include non-six-digit symbols (e.g. ETN 0197W0). MarketRankingService.refreshAll() passed all of them to StockReferenceService.refreshMissing(), and TossMarketDataClient.fetchStockNames() rejects any chunk containing a non-six-digit symbol with IllegalArgumentException. Every chunk failed, so the name cache never populated and RankingView.name was null for all rows (log: 종목명 조회 실패(200종목): IllegalArgumentException).

Fix: StockReferenceService.refreshSymbols() now filters to six-digit KRX symbols (\d{6}) before calling the name API. This covers all call paths (refreshMissing from rankings, refreshAll from universe + watchlist) in one place. nameOf() behavior is unchanged — KOSPI/KOSDAQ still resolve via MarketInstrument.displayName.

Changes

  • StockReferenceService.java: filter non-six-digit symbols in refreshSymbols() (3 lines + comment)
  • StockReferenceServiceTest.java: new test filtersNonSixDigitSymbolsBeforeNameLookup — asserts ETN-style symbols never reach fetchStockNames() while valid six-digit symbols do

Test plan

  • ./gradlew test --tests 'com.marketguard.collector.StockReferenceServiceTest' → pass
  • ./gradlew test --tests 'com.marketguard.collector.MarketRankingServiceTest' → pass
  • ./gradlew clean check --no-daemon --no-parallel → BUILD SUCCESSFUL (full suite)

Ranking responses can include ETN-style symbols (e.g. 0197W0) which
fetchStockNames() rejects with IllegalArgumentException, failing the
entire chunk. Filter to six-digit KRX symbols in refreshSymbols() so
ranking rows resolve their display names instead of showing null.

@mytrashcan mytrashcan left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Looks good — mergeable

Verified OK

  • Root cause is accurate: fetchStockNames() rejects any chunk containing a non-six-digit symbol, so a single ETN code (0197W0) from the ranking response failed every chunk and left the name cache empty.
  • Fix is minimal and correctly placed: filtering in refreshSymbols() covers both call paths (refreshMissing from rankings, refreshAll from universe + watchlist) without touching nameOf() semantics.
  • \d{6} predicate matches the existing validateSymbols() contract exactly — no behavior drift.
  • KOSPI/KOSDAQ market symbols still resolve via MarketInstrument.displayName() and never reach fetchStockNames().
  • New test proves the regression: ETN-style symbols are excluded from the upstream call while valid six-digit symbols still populate the cache.
  • Full suite passes: ./gradlew clean check → BUILD SUCCESSFUL.

Good Things

  • One-place fix with a clear comment explaining why the filter exists (ranking responses carry non-standard symbols).
  • Test asserts both the positive (name resolved) and negative (symbol never sent upstream) outcomes.

Reviewed by Hermes Agent - deepseek-v4-flash

@mytrashcan
mytrashcan merged commit 4f12b4c into main Jul 31, 2026
1 check passed
@mytrashcan
mytrashcan deleted the fix/ranking-name-lookup branch August 3, 2026 04:05
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