Skip to content

fix: Resolve error when checking pipeline parsing result - #15778

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
dcc123456:fix/bug-0608
Jun 8, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
dcc123456:fix/bug-0608

Conversation

@dcc123456

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

fix: Resolve error when checking pipeline parsing result

Type of change

  • Bug Fix (non-breaking change which fixes an issue)

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 8, 2026
@dcc123456
dcc123456 marked this pull request as draft June 8, 2026 09:59
@dcc123456
dcc123456 marked this pull request as ready for review June 8, 2026 09:59
@coderabbitai

coderabbitai Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR improves file type detection for document preview rendering. Image type validation moves from hardcoded extension lists to a centralized constant, and file extension extraction is made null-safe using optional chaining with a fallback to the cached document extension.

Changes

Document Preview File Type Handling

Layer / File(s) Summary
Centralized image type detection and null-safe file extension handling
web/src/components/document-preview/index.tsx, web/src/pages/dataflow-result/index.tsx
Image type detection transitions from a hardcoded extension array to Images constant from @/constants/common. File extension extraction is secured with optional chaining (documentInfo?.name?.split('.').pop()) and falls back to documentExtension instead of the literal 'visual' when unavailable.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

bug, size:M

Suggested reviewers

  • JinHai-CN
  • cike8899

Poem

🐰 A constant replaces the hardcoded line,
Image types now centralized and fine,
Optional chains keep nulls at bay,
Safe extensions brighten the day! 🎨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete and lacks substantive detail; it only repeats the title without explaining the problem, its impact, or the solution implemented. Add a detailed explanation of the bug (what error occurred, under what conditions), its impact, and how the changes fix it. Include information about the specific files and logic changes made.
Title check ❓ Inconclusive The title is vague and generic, using non-descriptive language that doesn't clarify the specific bug being fixed or which component is affected. Improve the title to be more specific about what error was resolved, such as 'fix: Handle missing document name in preview file type detection' or similar.
✅ Passed checks (3 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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/src/pages/dataflow-result/index.tsx (1)

69-74: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Incomplete fix - same null reference issue exists in non-agent flow.

Lines 71 and 73 use documentInfo?.name.split('.') which will throw an error if documentInfo.name is undefined or null (same issue that was fixed at line 66 for the agent flow).

For consistency and completeness, these should also use optional chaining:

🔒 Proposed fix to add optional chaining
     case 'doc':
-      return documentInfo?.name.split('.').pop() || 'doc';
+      return documentInfo?.name?.split('.').pop() || 'doc';
     case 'visual':
-      return documentInfo?.name.split('.').pop() || 'visual';
+      return documentInfo?.name?.split('.').pop() || 'visual';
🤖 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 `@web/src/pages/dataflow-result/index.tsx` around lines 69 - 74, The switch in
dataflow-result's type handling (switch on documentInfo?.type with cases 'doc'
and 'visual') still calls documentInfo?.name.split('.') which can throw if name
is null/undefined; update those expressions to safely access name (e.g., use
optional chaining on name before split and a fallback) so both the 'doc' and
'visual' branches mirror the agent-flow fix (replace
documentInfo?.name.split('.') with documentInfo?.name?.split('.')?.pop() ||
'doc' / 'visual' as appropriate).
🧹 Nitpick comments (1)
web/src/components/document-preview/index.tsx (1)

48-48: 💤 Low value

Good refactor - centralizes image type detection.

This change follows the DRY principle by using the centralized Images constant instead of a hardcoded array.

Optional: The entire file could be modernized to use .includes() instead of .indexOf() > -1 (lines 38, 43, 48, 53-65, 70, 75, 80, 85), but this change is consistent with the existing pattern and improves maintainability.

🤖 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 `@web/src/components/document-preview/index.tsx` at line 48, Replace the
repeated pattern of using Images.indexOf(fileType) > -1 with the clearer, modern
Array.prototype.includes usage across this component: locate the checks that
compare Images to fileType (e.g., the JSX conditional at
Images.indexOf(fileType) > -1 and the other indexOf occurrences around lines
where fileType and Images are used) and change them to Images.includes(fileType)
so the conditional reads more idiomatically and avoids the > -1 pattern; ensure
all occurrences in document-preview/index.tsx that reference Images.indexOf(...)
are updated to Images.includes(...).
🤖 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.

Outside diff comments:
In `@web/src/pages/dataflow-result/index.tsx`:
- Around line 69-74: The switch in dataflow-result's type handling (switch on
documentInfo?.type with cases 'doc' and 'visual') still calls
documentInfo?.name.split('.') which can throw if name is null/undefined; update
those expressions to safely access name (e.g., use optional chaining on name
before split and a fallback) so both the 'doc' and 'visual' branches mirror the
agent-flow fix (replace documentInfo?.name.split('.') with
documentInfo?.name?.split('.')?.pop() || 'doc' / 'visual' as appropriate).

---

Nitpick comments:
In `@web/src/components/document-preview/index.tsx`:
- Line 48: Replace the repeated pattern of using Images.indexOf(fileType) > -1
with the clearer, modern Array.prototype.includes usage across this component:
locate the checks that compare Images to fileType (e.g., the JSX conditional at
Images.indexOf(fileType) > -1 and the other indexOf occurrences around lines
where fileType and Images are used) and change them to Images.includes(fileType)
so the conditional reads more idiomatically and avoids the > -1 pattern; ensure
all occurrences in document-preview/index.tsx that reference Images.indexOf(...)
are updated to Images.includes(...).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a858960b-5010-4622-b4ac-9592849864a1

📥 Commits

Reviewing files that changed from the base of the PR and between 86b320e and 4f30896.

📒 Files selected for processing (2)
  • web/src/components/document-preview/index.tsx
  • web/src/pages/dataflow-result/index.tsx

@wangq8
wangq8 merged commit 7dd4030 into infiniflow:main Jun 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants