Skip to content

Conversation

@gsha22
Copy link

@gsha22 gsha22 commented Dec 8, 2025

📑 Summary

These fixes ensure that if there are extra characters after a task duration, an error is thrown instead of failing silently.

We also added a test to ensure that it throws errors on invalid duration tokens.

Resolves #6586

In association with the following doc pr: #7212

📏 Design Decisions

Added conditional logic in mermaid/src/diagrams/gantt/ganttDb.js on line 394 to ensure an error is thrown if check fails.

Our comment:

// If the string is not a valid ISO date (handled earlier) and it is
// also not a recognised duration token, that's an invalid duration
// token. Throw an error so the renderer fails loudly and the user
// gets a clear message instead of silently omitting the task.
// Example invalid tokens: `24de`, `24d+`, `24d=`, `24d7`.

📋 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 Dec 8, 2025

⚠️ No Changeset found

Latest commit: ae19587

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@netlify
Copy link

netlify bot commented Dec 8, 2025

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit ae19587
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/693a62959dfec40008396334
😎 Deploy Preview https://deploy-preview-7227--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 Dec 8, 2025

Open in StackBlitz

@mermaid-js/examples

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

mermaid

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

@mermaid-js/layout-elk

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

@mermaid-js/layout-tidy-tree

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

@mermaid-js/mermaid-zenuml

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

@mermaid-js/parser

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

@mermaid-js/tiny

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

commit: ae19587

@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.58%. Comparing base (39d070f) to head (ae19587).

Files with missing lines Patch % Lines
packages/mermaid/src/diagrams/gantt/ganttDb.js 84.61% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #7227      +/-   ##
==========================================
+ Coverage     3.56%   3.58%   +0.01%     
==========================================
  Files          473     473              
  Lines        47566   47577      +11     
  Branches       734     738       +4     
==========================================
+ Hits          1696    1705       +9     
- Misses       45870   45872       +2     
Flag Coverage Δ
unit 3.58% <84.61%> (+0.01%) ⬆️

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

Files with missing lines Coverage Δ
packages/mermaid/src/diagrams/gantt/ganttDb.js 77.13% <84.61%> (+0.06%) ⬆️
🚀 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 Dec 8, 2025

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

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 4 changed Dec 11, 2025, 6:29 AM

Copy link
Contributor

@omkarht omkarht left a comment

Choose a reason for hiding this comment

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

Implementation is excellent, but test coverage is insufficient, please add tests for all invalid patterns mentioned in your comments plus regression tests for valid duration and edge cases (currently 1 test, need 5+).

@gsha22
Copy link
Author

gsha22 commented Dec 11, 2025

Implementation is excellent, but test coverage is insufficient, please add tests for all invalid patterns mentioned in your comments plus regression tests for valid duration and edge cases (currently 1 test, need 5+).

Thank you! Added some more pattern tests, as well as some regression tests for sanity check. Let me know if you need anything else!

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.

Gantt: Task duration fails silently if it contains extra characters like e, 8, +, =, ...etc

2 participants