Skip to content

fix: prevent TypeError on undefined currentPlan.type and path-shim extname#10161

Draft
Copilot wants to merge 2 commits into
developfrom
copilot/fix-application-error-update
Draft

fix: prevent TypeError on undefined currentPlan.type and path-shim extname#10161
Copilot wants to merge 2 commits into
developfrom
copilot/fix-application-error-update

Conversation

Copilot AI commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Two crash paths that produce TypeError: Cannot read properties of undefined in the renderer bundle.

mock-response-extractor.tsx — unsafe optional chain

currentPlan is loaded from localStorage as JSON.parse(... || '{}'). When no plan is cached, it is {} — truthy, so currentPlan?.type still evaluates to undefined, and calling .includes() on it throws.

// before
const isEnterprise = currentPlan?.type.includes('enterprise');

// after
const isEnterprise = currentPlan?.type?.includes('enterprise');

path-shim.ts — missing null guard

This file is the Vite path alias for the renderer bundle (vite.config.ts aliases 'path'path-shim.ts). extname called p.lastIndexOf('.') with no guard — passing undefined throws exactly the reported error. Returns '' for falsy input, matching Node.js path.extname behaviour.

// before
export const extname = (p: string) => p.slice(p.lastIndexOf('.'));

// after
export const extname = (p: string | undefined | null) => (p ? p.slice(p.lastIndexOf('.')) : '');

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Fix application error - update fix: prevent TypeError on undefined currentPlan.type and path-shim extname Jun 25, 2026
Copilot AI requested a review from notjaywu June 25, 2026 04:32
@notjaywu notjaywu removed their assignment Jun 25, 2026
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.

3 participants