Skip to content

[FIX] 필드명 오류 수정 | 뉴스별 파급 경로 그래프가 잘못된 인덱스를 참조해 undefined.marketCap로 터지던 버그 수정 - #29

Merged
suwonthugger merged 1 commit into
mainfrom
fix/28-impact-field-name
Jul 28, 2026
Merged

[FIX] 필드명 오류 수정 | 뉴스별 파급 경로 그래프가 잘못된 인덱스를 참조해 undefined.marketCap로 터지던 버그 수정#29
suwonthugger merged 1 commit into
mainfrom
fix/28-impact-field-name

Conversation

@suwonthugger

@suwonthugger suwonthugger commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

👥 작업 배경 및 목적

  • 뉴스별 파급 경로 그래프(GraphPanel, focus 모드)가 실제 impact 응답 데이터가 아니라 옛 데모 온톨로지(mocks/graph/data.ts) 기반 전역 인덱스로 노드 메타데이터를 조회하고 있었음. 실 백엔드가 데모와 다른 id 체계로 노드를 내려주면 조회에 실패해 Cannot read properties of undefined (reading 'marketCap')로 크래시하는 버그를 수정.
  • 관련 Issue 번호: Close [FIX] 필드명 오류 수정 #28

🛠️ 주요 변경 사항

  • src/components/graph/GraphPanel.tsx : Scene2index: GraphIndex 필드 추가. buildFocusScene은 실제 impactGraph.nodes/edges로 만든 자기 인덱스를, buildAllScenefullGraphIndex를 각각 씬에 실어 보내도록 수정. GraphCanvas는 별도 index prop 대신 scene2.index를 사용
  • src/components/graph/NetworkView.tsx : GraphCanvas에 더 이상 필요 없는 index prop 제거
  • src/utils/graph/layout.ts : 이제 완전히 미사용이 된 옛 데모 전용 graphIndex export 및 관련 import 제거
  • 코드 리뷰어가 볼 부분: GraphPanel.tsxScene2 인터페이스와 buildFocusScene/buildAllScene이 각각 어떤 인덱스를 채워 넣는지, GraphCanvas가 prop 대신 scene2.index를 쓰도록 바뀐 부분

🧪 테스트 결과 (선택)

  • 데모 온톨로지와 무관한 임의의 id(TEST_A/TEST_B, 티커 999901/999902)로 목 응답을 만들어 렌더링 — 수정 전 크래시 재현, 수정 후 카드 크기(capSize)까지 정확하게 정상 렌더링되는 것 확인
  • 전체 관계망 렌더링/검색/하이라이트, 기존 뉴스별 파급 경로 회귀 테스트 통과
  • tsc --noEmit, pnpm lint 클린
    PRBODY)

👥 작업 배경 및 목적

  • 뉴스별 파급 경로 그래프(GraphPanel, focus 모드)가 실제 impact 응답 데이터가 아니라 옛 데모 온톨로지(mocks/graph/data.ts) 기반 전역 인덱스로 노드 메타데이터를 조회하고 있었음. 실 백엔드가 데모와 다른 id 체계로 노드를 내려주면 조회에 실패해 Cannot read properties of undefined (reading 'marketCap')로 크래시하는 버그를 수정.
  • 관련 Issue 번호: #이슈번호

🛠️ 주요 변경 사항

  • src/components/graph/GraphPanel.tsx : Scene2index: GraphIndex 필드 추가. buildFocusScene은 실제 impactGraph.nodes/edges로 만든 자기 인덱스를, buildAllScenefullGraphIndex를 각각 씬에 실어 보내도록 수정. GraphCanvas는 별도 index prop 대신 scene2.index를 사용
  • src/components/graph/NetworkView.tsx : GraphCanvas에 더 이상 필요 없는 index prop 제거
  • src/utils/graph/layout.ts : 이제 완전히 미사용이 된 옛 데모 전용 graphIndex export 및 관련 import 제거
  • 코드 리뷰어가 볼 부분: GraphPanel.tsxScene2 인터페이스와 buildFocusScene/buildAllScene이 각각 어떤 인덱스를 채워 넣는지, GraphCanvas가 prop 대신 scene2.index를 쓰도록 바뀐 부분

🧪 테스트 결과 (선택)

  • 데모 온톨로지와 무관한 임의의 id(TEST_A/TEST_B, 티커 999901/999902)로 목 응답을 만들어 렌더링 — 수정 전 크래시 재현, 수정 후 카드 크기(capSize)까지 정확하게 정상 렌더링되는 것 확인
  • 전체 관계망 렌더링/검색/하이라이트, 기존 뉴스별 파급 경로 회귀 테스트 통과
  • tsc --noEmit, pnpm lint 클린

Summary by CodeRabbit

  • 개선 사항
    • 그래프 화면이 현재 보기 모드에 맞는 관계망 데이터를 사용하도록 개선되었습니다.
    • 뉴스 파급 중심 보기에서는 해당 뉴스의 서브그래프가, 전체 관계망 보기에서는 전체 그래프가 정확히 표시됩니다.
    • 그래프 렌더링 과정이 단순화되어 화면별 데이터 표시의 일관성과 안정성이 향상되었습니다.

GraphCanvas가 focus 모드(뉴스별 파급 경로)에서도 옛 데모 온톨로지 기반
전역 graphIndex(mocks/graph/data.ts, id가 'sk'/'ss' 같은 문자열)로 노드
메타데이터를 조회하고 있었다. buildFocusScene은 실제 impactGraph.nodes/
edges로 만든 자기만의 index를 이미 갖고 있었는데 그게 GraphCanvas까지
전달되지 않아서, 실 백엔드가 데모와 다른 id 체계를 내려주면 조회가
실패(undefined)하고 sizeOf(undefined)에서 marketCap을 읽다 크래시했다.

Scene2에 index 필드를 추가해 buildFocusScene/buildAllScene이 각자
자기 데이터에 맞는 인덱스(전자는 impactGraph 기반, 후자는
fullGraphIndex)를 함께 실어 보내도록 하고, GraphCanvas는 scene2.index를
쓰도록 변경 — 별도 index prop과 옛 graphIndex export(이제 완전히
미사용)는 제거.

데모 온톨로지와 무관한 임의의 id("TEST_A"/"TEST_B")로 응답을 흉내내서
수정 전엔 크래시, 수정 후엔 정상 렌더링(카드 크기까지 정확)되는 것을
직접 확인했다. 전체 관계망 렌더링/검색/하이라이트, 기존 뉴스 파급 경로
회귀도 재확인.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@suwonthugger suwonthugger linked an issue Jul 28, 2026 that may be closed by this pull request
2 tasks
@suwonthugger suwonthugger self-assigned this Jul 28, 2026
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

그래프 레이아웃의 모듈 전역 graphIndex를 제거하고, Scene2가 모드별 GraphIndex를 보유하도록 변경했다. GraphCanvasNetworkView는 별도 인덱스 대신 씬의 인덱스를 사용한다.

Changes

GraphIndex 전달 구조

Layer / File(s) Summary
명시적 GraphIndex 소유권
src/utils/graph/layout.ts, src/components/graph/GraphPanel.tsx
레이아웃 모듈의 전역 graphIndex와 관련 온톨로지 import를 제거하고 외부에서 전달된 GraphIndex 사용 구조를 유지한다.
씬 및 캔버스 연결
src/components/graph/GraphPanel.tsx, src/components/graph/NetworkView.tsx
Scene2index를 추가하고 focus/all 씬에 인덱스를 포함하며, GraphCanvasNetworkViewscene2.index를 사용하도록 변경한다.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • koscom-team01/koslink-fe#7: BFS 및 graphIndex 인덱싱과 GraphPanel 그래프 렌더링 경로를 도입한 변경입니다.
  • koscom-team01/koslink-fe#12: GraphPanelNetworkView의 그래프 뷰 호출 및 속성 전달 구조를 리팩터링한 변경입니다.
  • koscom-team01/koslink-fe#19: 전역 graphIndex 제거와 명시적 그래프 데이터·인덱스 전달에 관한 변경입니다.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed 제목이 버그 수정의 핵심인 뉴스별 파급 경로 그래프 인덱스 오류를 직접적으로 잘 설명합니다.
Description check ✅ Passed 요구된 배경/목적, 주요 변경 사항, 테스트 결과 섹션과 이슈 번호가 모두 포함되어 있습니다.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/28-impact-field-name

Comment @coderabbitai help to get the list of available commands.

@suwonthugger suwonthugger changed the title fix: 뉴스별 파급 경로 그래프가 잘못된 인덱스를 참조해 undefined.marketCap로 터지던 버그 수정 [FIX] 필드명 오류 수정 | 뉴스별 파급 경로 그래프가 잘못된 인덱스를 참조해 undefined.marketCap로 터지던 버그 수정 Jul 28, 2026
@suwonthugger
suwonthugger merged commit a638a20 into main Jul 28, 2026
1 of 2 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/graph/GraphPanel.tsx`:
- Around line 283-286: Update the cache handling around the scene2.index
assignment so changing the scene-specific index invalidates both prevNodesRef
and prevEdgesRef before cached objects can be reused. Track the previous index
identity and clear both caches whenever the index changes, preserving cache
reuse when the same index remains active.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1a069fdd-0ed9-4154-a449-95a8385c32b5

📥 Commits

Reviewing files that changed from the base of the PR and between a916bab and 27a7aa5.

📒 Files selected for processing (3)
  • src/components/graph/GraphPanel.tsx
  • src/components/graph/NetworkView.tsx
  • src/utils/graph/layout.ts
💤 Files with no reviewable changes (1)
  • src/utils/graph/layout.ts

Comment on lines +283 to +286
// 씬마다 자기 데이터에 맞는 인덱스를 실어 보낸다(focus=뉴스별 impactGraph,
// all=graph.json) — 두 데이터셋의 id 체계가 다르므로 고정된 전역 인덱스를
// 쓰면 다른 쪽 모드에서 노드를 못 찾아 undefined.marketCap 등으로 터진다.
const index = scene2.index

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

씬별 index 변경 시 노드·엣지 캐시를 무효화해야 합니다.

scene2.index를 새로 읽어도 prevNodesRefprevEdgesRef는 유지됩니다. 이후 id와 시각 상태가 같으면 이전 객체를 재사용하므로, 뉴스 전환 시 새 인덱스의 노드명·크기·위치 또는 엣지 polarity 색상이 반영되지 않을 수 있습니다. 캐시 항목에 index identity를 포함하거나, 인덱스가 바뀔 때 두 캐시를 초기화하세요.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/graph/GraphPanel.tsx` around lines 283 - 286, Update the cache
handling around the scene2.index assignment so changing the scene-specific index
invalidates both prevNodesRef and prevEdgesRef before cached objects can be
reused. Track the previous index identity and clear both caches whenever the
index changes, preserving cache reuse when the same index remains active.

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.

[FIX] 필드명 오류 수정

1 participant