Skip to content

fix: resolve 4 bugs in Draftdeckai - #1466

Closed
saurabhhhcodes wants to merge 1 commit into
Muneerali199:mainfrom
saurabhhhcodes:fix/Draftdeckai-90211
Closed

fix: resolve 4 bugs in Draftdeckai#1466
saurabhhhcodes wants to merge 1 commit into
Muneerali199:mainfrom
saurabhhhcodes:fix/Draftdeckai-90211

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes real bugs found in the codebase:

  • Added explicit radix to parseInt: without 10, strings like '0x1F' or '08' parse in unintended bases.
  • Replaced innerHTML assignment with textContent: prevents HTML injection / XSS and is faster since it does not parse markup.
  • Replaced arr[arr.length - 1] with .at(-1): cleaner access to the last element.
  • Added rejection handler to Promise.all: an unhandled rejection in any input promise previously crashed silently.

Type of Change

  • Bug fix (non-breaking change fixing an issue)

How Has This Been Tested?

  • Local manual testing

Checklist

  • My code follows the style guidelines
  • I have performed a self-review

Related Issue

Ref: #1465

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling during export operations to make failures easier to diagnose.
    • Strengthened diagram preview updates for more reliable rendering.
    • Improved slide count handling when creating mobile presentations.
    • Improved resume field updates for more consistent editing behavior.

@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Someone is attempting to deploy a commit to the muneeralimca2025-5238's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The changes add export rejection logging and replace several JavaScript patterns for DOM clearing, decimal parsing, and final-path access.

Changes

Runtime cleanup updates

Layer / File(s) Summary
Export rejection logging
app/dashboard/export/page.tsx
Adds a trailing rejection handler that logs Promise.all failures.
Rendering, input, and path updates
components/diagram/diagram-preview.tsx, components/presentation/mobile-presentation-generator.tsx, components/resume/resume-preview.tsx
Clears the diagram container with textContent, parses slide counts with radix 10, and accesses the final resume field path segment with path.at(-1).

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

Possibly related PRs

Suggested reviewers: muneerali199

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the summary, bug-fix type, testing, and issue reference but omits dependencies, detailed test steps, screenshots, and most checklist items. Add the missing template sections, including dependencies, detailed reproducible test steps, UI screenshots if applicable, and the remaining checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the four bug fixes in the pull request.
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.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Biome (2.5.6)
app/dashboard/export/page.tsx

File contains syntax errors that prevent linting: Line 406: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


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.

@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: 2

Caution

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

⚠️ Outside diff range comments (1)
components/diagram/diagram-preview.tsx (1)

193-204: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Finish the XSS surface cleanup.

textContent removes the stale diagram, but Mermaid still writes SVG into a DOM node with innerHTML. With securityLevel: "loose", this path can render HTML labels generated from visualContent/Mermaid code. Sanitize the rendered SVG before insertion, or render only trusted Mermaid sources with strict/sandbox and replace the loose innerHTML with a safe DOM parse path.

🤖 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 `@components/diagram/diagram-preview.tsx` around lines 193 - 204, Sanitize the
SVG returned by mermaid.render before inserting it in the diagramContainer
created by the render flow, eliminating the direct unsafe innerHTML assignment
while preserving diagram rendering. Use the project’s established sanitization
utility, or configure Mermaid to strict/sandbox and parse the sanitized SVG
through a safe DOM path; ensure content derived from visualContent/code cannot
introduce executable HTML.
🤖 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 `@app/dashboard/export/page.tsx`:
- Around line 405-406: Remove the detached .catch expression after the
ExportPage component; it is not attached to a Promise and causes invalid
TypeScript syntax. Keep fetchStats’s existing surrounding try/catch as the sole
Promise.all failure handler, unless logging is explicitly moved onto the
Promise.all expression itself.

In `@components/presentation/mobile-presentation-generator.tsx`:
- Line 540: Update the pageCount input handler to clamp the parsed value to a
minimum of 3 before applying the MAX_FREE_PAGES upper bound, ensuring negative
or otherwise below-minimum input never reaches the API. Preserve the existing
fallback behavior for invalid input and use the surrounding page-count update
logic in the mobile presentation generator.

---

Outside diff comments:
In `@components/diagram/diagram-preview.tsx`:
- Around line 193-204: Sanitize the SVG returned by mermaid.render before
inserting it in the diagramContainer created by the render flow, eliminating the
direct unsafe innerHTML assignment while preserving diagram rendering. Use the
project’s established sanitization utility, or configure Mermaid to
strict/sandbox and parse the sanitized SVG through a safe DOM path; ensure
content derived from visualContent/code cannot introduce executable HTML.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fa4febc9-f803-4e40-b5fd-18e1bfc64f43

📥 Commits

Reviewing files that changed from the base of the PR and between 2eac4d0 and 04bd718.

📒 Files selected for processing (4)
  • app/dashboard/export/page.tsx
  • components/diagram/diagram-preview.tsx
  • components/presentation/mobile-presentation-generator.tsx
  • components/resume/resume-preview.tsx

Comment on lines +405 to +406

.catch(err => console.error("Promise.all failed:", err)); No newline at end of file

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 | 🔴 Critical | ⚡ Quick win

Remove the detached .catch before merging.

Line 406 is invalid TypeScript syntax because it follows the closing brace of ExportPage instead of a Promise expression. The file cannot compile.

fetchStats already catches Promise.all failures through its surrounding try/catch at Lines 92-155. Remove Lines 405-406, or attach the handler directly to the Promise.all expression if separate logging is required.

Proposed fix
-}
-
-.catch(err => console.error("Promise.all failed:", err));
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.catch(err => console.error("Promise.all failed:", err));
}
🧰 Tools
🪛 Biome (2.5.6)

[error] 406-406: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'.

(parse)

🤖 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 `@app/dashboard/export/page.tsx` around lines 405 - 406, Remove the detached
.catch expression after the ExportPage component; it is not attached to a
Promise and causes invalid TypeScript syntax. Keep fetchStats’s existing
surrounding try/catch as the sole Promise.all failure handler, unless logging is
explicitly moved onto the Promise.all expression itself.

Source: Linters/SAST tools

onChange={(e) =>
setPageCount(
Math.min(parseInt(e.target.value) || 3, MAX_FREE_PAGES),
Math.min(parseInt(e.target.value, 10) || 3, MAX_FREE_PAGES),

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 | 🟡 Minor | ⚡ Quick win

Clamp pageCount to the lower bound.

For input -1, parseInt(e.target.value, 10) returns -1, and Math.min stores -1. The HTML min="3" attribute does not prevent this state update. Clamp the value with Math.max(3, ...) before sending pageCount to the API.

Proposed fix
-                        Math.min(parseInt(e.target.value, 10) || 3, MAX_FREE_PAGES),
+                        Math.max(
+                          3,
+                          Math.min(
+                            parseInt(e.target.value, 10) || 3,
+                            MAX_FREE_PAGES,
+                          ),
+                        ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Math.min(parseInt(e.target.value, 10) || 3, MAX_FREE_PAGES),
Math.max(
3,
Math.min(
parseInt(e.target.value, 10) || 3,
MAX_FREE_PAGES,
),
),
🤖 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 `@components/presentation/mobile-presentation-generator.tsx` at line 540,
Update the pageCount input handler to clamp the parsed value to a minimum of 3
before applying the MAX_FREE_PAGES upper bound, ensuring negative or otherwise
below-minimum input never reaches the API. Preserve the existing fallback
behavior for invalid input and use the surrounding page-count update logic in
the mobile presentation generator.

@netlify

netlify Bot commented Aug 8, 2026

Copy link
Copy Markdown

👷 Deploy request for docmagic-muneer pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 04bd718

@netlify

netlify Bot commented Aug 8, 2026

Copy link
Copy Markdown

👷 Deploy request for docmagic1 pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 04bd718

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