Skip to content

Commit c323d78

Browse files
authored
fix: Frontend crash due to invalid citations (#1002)
1 parent cfdbd89 commit c323d78

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

code/frontend/src/components/Answer/AnswerParser.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function parseAnswer(answer: AskResponse): ParsedAnswer {
1919
// Replacing the links/citations with number
2020
let citationIndex = link.slice(lengthDocN, link.length - 1);
2121
let citation = cloneDeep(answer.citations[Number(citationIndex) - 1]) as Citation;
22-
if (!filteredCitations.find((c) => c.id === citationIndex)) {
22+
if (!filteredCitations.find((c) => c.id === citationIndex) && citation !== undefined) {
2323
answerText = answerText.replaceAll(link, ` ^${++citationReindex}^ `);
2424
citation.id = citationIndex; // original doc index to de-dupe
2525
citation.reindex_id = citationReindex.toString(); // reindex from 1 for display

0 commit comments

Comments
 (0)