Skip to content

fix(message-parser): dynamic ASTNode type from Types schema#39189

Closed
Harshit2405-2004 wants to merge 1 commit intoRocketChat:developfrom
Harshit2405-2004:fix/astnode-union-types
Closed

fix(message-parser): dynamic ASTNode type from Types schema#39189
Harshit2405-2004 wants to merge 1 commit intoRocketChat:developfrom
Harshit2405-2004:fix/astnode-union-types

Conversation

@Harshit2405-2004
Copy link
Copy Markdown
Contributor

@Harshit2405-2004 Harshit2405-2004 commented Feb 28, 2026

Closes #39057 and Fixes #39057 by deriving the ASTNode union strictly from the Types dictionary interface. Also populates the missing Types mappings for Timestamp, Blockquote, KaTeX, and InlineKaTeX.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed type safety for AST node guards, restoring correct type checking for timestamps, images, lists, KaTeX, and blockquotes.

Closes RocketChat#39057

- Adds missing Types dictionary entries (TIMESTAMP, BLOCKQUOTE, KATEX, INLINE_KATEX)

- Maps ASTNode globally to Types[keyof Types] to prevent drift
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Feb 28, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 28, 2026

🦋 Changeset detected

Latest commit: 283fb14

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

This PR includes changesets to release 42 packages
Name Type
@rocket.chat/message-parser Patch
@rocket.chat/meteor Patch
@rocket.chat/core-services Patch
@rocket.chat/core-typings Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/rest-typings Patch
@rocket.chat/pdf-worker Patch
rocketchat-services Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/presence Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/http-router Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/models Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/server-fetch 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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c30636 and 283fb14.

📒 Files selected for processing (2)
  • .changeset/fix-astnode-completeness.md
  • packages/message-parser/src/definitions.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/message-parser/src/definitions.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38219
File: packages/core-typings/src/cloud/Announcement.ts:5-6
Timestamp: 2026-01-17T01:51:47.764Z
Learning: In packages/core-typings/src/cloud/Announcement.ts, the AnnouncementSchema.createdBy field intentionally overrides IBannerSchema.createdBy (object with _id and optional username) with a string enum ['cloud', 'system'] to match existing runtime behavior. This is documented as technical debt with a FIXME comment at apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts:53 and should not be flagged as an error until the runtime behavior is corrected.
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • packages/message-parser/src/definitions.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • packages/message-parser/src/definitions.ts
🔇 Additional comments (4)
packages/message-parser/src/definitions.ts (3)

54-62: Emoji union branches are explicitly modeled and look correct.

This preserves both shortcode and unicode forms without widening the node shape.


202-205: Missing Types mappings are now covered cleanly.

Adding these keys closes the known schema coverage gaps for emitted AST node kinds.


208-208: Great change: ASTNode is now drift-proofed against Types.

This is the right fix to keep compile-time unions aligned with parser schema changes.

.changeset/fix-astnode-completeness.md (1)

1-5: Changeset entry is clear and aligned with the implementation.

It correctly communicates the AST typing fix as a patch-level change.


Walkthrough

This fix addresses incomplete ASTNode type definitions in the message parser. Missing node types (TIMESTAMP, BLOCKQUOTE, KATEX, INLINE_KATEX) are added to the Types mapping, and ASTNode is refactored from an explicit union to a dynamic lookup using Types[keyof Types]. A changelog entry documents the patch release.

Changes

Cohort / File(s) Summary
Changelog
.changeset/fix-astnode-completeness.md
Added changelog entry documenting the patch fix to ASTNode union type and Types dictionary.
Type Definitions
packages/message-parser/src/definitions.ts
Added missing discriminator types (TIMESTAMP, BLOCKQUOTE, KATEX, INLINE_KATEX) to Types mapping; refactored ASTNode from explicit union to dynamic lookup via Types[keyof Types]; minor formatting adjustments to EMOJI branch.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

type: bug

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: making ASTNode dynamically derived from the Types schema to fix incomplete type coverage.
Linked Issues check ✅ Passed The PR fully addresses issue #39057 by adding missing Types mappings (TIMESTAMP, BLOCKQUOTE, KATEX, INLINE_KATEX) and deriving ASTNode from Types to ensure type guards work correctly.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the ASTNode union type completeness issue; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

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

@Harshit2405-2004
Copy link
Copy Markdown
Contributor Author

Closing scope too narrow, consolidating.

@ggazzo
Copy link
Copy Markdown
Member

ggazzo commented Apr 17, 2026

Hey @Harshit2405-2004, thank you for your contribution! 🙏

Your changes have been consolidated into #39853, where we merged all message-parser PRs together to make it easier to test and validate everything as a single unit.

That PR has already been merged into develop, so your work is included. Closing this one — thanks again!

@ggazzo ggazzo closed this Apr 17, 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.

Message parser ASTNode types are incomplete and break type narrowing for valid parser output

2 participants