Skip to content

7162: add line and column numbers to parse error messages#7333

Merged
ashishjain0512 merged 2 commits intodevelopfrom
feat/7162-parser-error-line-column-numbers
Jan 23, 2026
Merged

7162: add line and column numbers to parse error messages#7333
ashishjain0512 merged 2 commits intodevelopfrom
feat/7162-parser-error-line-column-numbers

Conversation

@omkarht
Copy link
Contributor

@omkarht omkarht commented Jan 21, 2026

📑 Summary

Enhanced the MermaidParseError class to include line and column numbers in all parser error messages, significantly improving debugging experience. Previously, syntax errors only showed generic messages without location information. Now all diagram types (radar, pie, info, packet, etc.) display errors in the format: Parse error on line X, column Y: <error details>. Added comprehensive tests to verify error formatting and updated existing tests to match the new format.

Resolves #7162

📏 Design Decisions

Describe the way your implementation works or what design decisions you made if applicable.

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added necessary unit/e2e tests.
  • 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
  • 🦋 If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

@changeset-bot
Copy link

changeset-bot bot commented Jan 21, 2026

🦋 Changeset detected

Latest commit: fd3fc50

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@mermaid-js/parser Patch
mermaid Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented Jan 21, 2026

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit fd3fc50
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/6970b11dfe847d000910b50f
😎 Deploy Preview https://deploy-preview-7333--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 21, 2026

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/examples@7333

mermaid

npm i https://pkg.pr.new/mermaid-js/mermaid@7333

@mermaid-js/layout-elk

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-elk@7333

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-tidy-tree@7333

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/mermaid-zenuml@7333

@mermaid-js/parser

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/parser@7333

@mermaid-js/tiny

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/tiny@7333

commit: fd3fc50

@codecov
Copy link

codecov bot commented Jan 21, 2026

Codecov Report

❌ Patch coverage is 0% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.59%. Comparing base (4261d3e) to head (fd3fc50).
⚠️ Report is 58 commits behind head on develop.

Files with missing lines Patch % Lines
packages/parser/src/parse.ts 0.00% 20 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #7333      +/-   ##
==========================================
- Coverage     3.59%   3.59%   -0.01%     
==========================================
  Files          474     474              
  Lines        47471   47489      +18     
  Branches       740     740              
==========================================
  Hits          1705    1705              
- Misses       45766   45784      +18     
Flag Coverage Δ
unit 3.59% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/parser/src/parse.ts 1.26% <0.00%> (-0.38%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@argos-ci
Copy link

argos-ci bot commented Jan 21, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Jan 21, 2026, 11:09 AM

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances parser error reporting so that syntax and lexer errors across Mermaid diagram types include explicit line and column information, improving debugging and aligning with the behavior requested in issue #7162.

Changes:

  • Updated MermaidParseError to wrap lexer and parser errors with standardized, location-aware messages (Lexer error on line X, column Y: and Parse error on line X, column Y:).
  • Added radar parser tests that validate the presence and formatting of line/column information in both lexer and parser error scenarios.
  • Updated the info diagram tests to match the new error message format and added a changeset entry documenting the behavior change in @mermaid-js/parser.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/parser/src/parse.ts Centralizes error formatting in MermaidParseError to include line and column numbers for lexer and parser errors, affecting all diagram types that use the shared parser.
packages/parser/tests/radar.test.ts Extends radar grammar tests to call the shared async parse API and assert that thrown MermaidParseError instances include line/column information and the standardized Parse error on line X, column Y prefix.
packages/mermaid/src/diagrams/info/info.spec.ts Adjusts info diagram parser tests to assert the new lexer error message format including line and column metadata.
.changeset/slow-bees-mate.md Records a patch-level changeset for @mermaid-js/parser describing the enhanced parser error messages for release notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ashishjain0512 ashishjain0512 added this pull request to the merge queue Jan 23, 2026
Merged via the queue into develop with commit 11f3790 Jan 23, 2026
35 checks passed
@ashishjain0512 ashishjain0512 deleted the feat/7162-parser-error-line-column-numbers branch January 23, 2026 13:15
This was referenced Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Radar: syntax error without line number

3 participants