Skip to content

fix(stringify): do not drop regex flags COMPASS-10988 - #931

Closed
mabaasit wants to merge 1 commit into
mainfrom
COMPASS-10988
Closed

mabaasit wants to merge 1 commit into
mainfrom
COMPASS-10988

Conversation

@mabaasit

Copy link
Copy Markdown
Collaborator

Description

Open Questions

Checklist

Copilot AI balanced review requested due to automatic review settings October 20, 2026 11:29
@mabaasit
mabaasit requested review from a team as code owners October 20, 2026 11:29
@mabaasit
mabaasit requested a review from dudaschar October 20, 2026 11:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused change preserves existing formatting and adds regression coverage, with no identified blocking issues.

No open issues 🎉

What changed in this PR

Fixes regular-expression serialization in shell-bson-parser so flags are preserved.

Changes:

  • Uses RegExp.flags instead of collecting only g, i, and m.
  • Adds regression coverage for preserving dgimsuy.
File Description
packages/​shell-bson-parser/​src/​stringify.ts Preserves all flags when serializing regular expressions.
packages/​shell-bson-parser/​src/​stringify.spec.ts Tests serialization with multiple flags.

Review effort: Balanced


return `RegExp(${JSON.stringify(v.source)}${hasOptions ? `, '${o}'` : ''})`;
const flags = v.flags;
return `RegExp(${JSON.stringify(v.source)}${flags ? `, '${flags}'` : ''})`;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

g, i and m is the common overlap between JS regular expressions (which this function handles) and BSON regular expressions (which do not support other flags). Are we sure this is the right change?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I am trying to figure out what the fix would look like in this case. We can handle this in parse as well and throw for invalid flags (which would be same as bson's allowed regex flags). It would still leave the issue as is in stringify, but we usually do that after parse inside compass.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we articulate what the bug is that we're trying to fix here? Unfortunately, neither the JIRA ticket, nor the PR description, nor the commit message actually explain this

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

IIRC it was within Compass querybar that a user would type regex and in saved list it showed without all the flags that typed. I am not able to get that state anymore within Compass and will close the ticket and PR.

@mabaasit mabaasit closed this Oct 23, 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