Skip to content

fix(prompt-files): avoid crash when <system> tag is unclosed#12519

Open
Pluviobyte wants to merge 1 commit into
continuedev:mainfrom
Pluviobyte:fix/parse-prompt-file-missing-system-close
Open

fix(prompt-files): avoid crash when <system> tag is unclosed#12519
Pluviobyte wants to merge 1 commit into
continuedev:mainfrom
Pluviobyte:fix/parse-prompt-file-missing-system-close

Conversation

@Pluviobyte
Copy link
Copy Markdown

@Pluviobyte Pluviobyte commented May 29, 2026

Description

parsePromptFile only checks for an opening <system> tag before splitting on the closing one:

if (prompt.includes("<system>")) {
  systemMessage = prompt.split("<system>")[1].split("</system>")[0].trim();
  prompt = prompt.split("</system>")[1].trim();
}

If a .prompt file contains <system> but omits the closing </system> (an easy authoring typo), prompt.split("</system>") returns a single-element array, so [1] is undefined and .trim() throws:

TypeError: Cannot read properties of undefined (reading 'trim')

Because .prompt files are parsed during config / slash-command load, one malformed file breaks loading instead of degrading gracefully.

Fix

Require both <system> and </system> before parsing the system block. An unclosed tag now falls through and the entire body is treated as the prompt (no crash).

Checklist

  • I've read the contributing guide
  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Screen recording or screenshot

N/A — parser crash fix; covered by the new tests.

Tests

Added core/promptFiles/parsePromptFile.vitest.ts covering:

  • a well-formed <system>…</system> block (parsed correctly)
  • an unclosed <system> tag (no longer throws; whole body kept as the prompt)
  • no system block at all

Verified the unclosed case fails on the old code with Cannot read properties of undefined (reading 'trim') and passes with the fix. tsc -p ./ --noEmit reports 0 errors and prettier --check passes locally.

Made with Cursor


Summary by cubic

Fix prevents a crash when a .prompt file includes without a closing . The parser now only extracts a system message if both tags are present; otherwise it treats the content as the prompt.

  • Bug Fixes
    • Check for both and before parsing to avoid split/trim TypeError.
    • Add tests for closed, unclosed, and no-system cases.

Written for commit 84c0f34. Summary will update on new commits.

Review in cubic

parsePromptFile only checked for an opening `<system>` tag before running
`prompt.split("</system>")[1].trim()`. A `.prompt` file that contains
`<system>` but omits the closing `</system>` makes that split return a
single-element array, so `[1]` is undefined and `.trim()` throws
`TypeError: Cannot read properties of undefined (reading 'trim')`,
failing config load over a simple authoring typo.

Require both tags before parsing the system block; an unclosed tag now
falls through and the whole body is treated as the prompt. Adds tests for
the closed, unclosed, and no-system cases.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Pluviobyte Pluviobyte requested a review from a team as a code owner May 29, 2026 06:31
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 29, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

@Pluviobyte
Copy link
Copy Markdown
Author

I checked the remaining failing statuses. The GitHub Actions checks are green, but the Continuous AI failure target returns Cannot GET /api/agent-check-summary/..., so there is no actionable failure detail exposed from the external check.

Could a maintainer rerun/waive the Continuous AI statuses or share the specific task output? I can address any concrete finding once the external check exposes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant