Skip to content

feat: Notify Invalid RegExp Patterns - #261

Merged
Martin Aeschlimann (aeschli) merged 7 commits into
microsoft:mainfrom
aedenmurray:feature/notify-invalid
Jun 6, 2025
Merged

Martin Aeschlimann (aeschli) merged 7 commits into
microsoft:mainfrom
aedenmurray:feature/notify-invalid

Conversation

@aedenmurray

Copy link
Copy Markdown
Contributor

This PR allows users to be notified when an invalid regex pattern is encountered.
This is useful if a JSON schema is published that contains patterns that are not supported by new RegExp().
For example, as of time of writing, the version pattern for the composer.json schema includes a possessive quantifier (*+) that is not supported by JavaScript (see composer.json schema definition).

@aedenmurray

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Shadowscape, Inc."

Comment thread src/test/parser.test.ts Outdated
@aeschli

Martin Aeschlimann (aeschli) commented Apr 25, 2025 •

Copy link
Copy Markdown
Collaborator

The JSON schema spec says that regexes must match the Regular Expression specification from JavaScript. https://json-schema.org/understanding-json-schema/reference/regular_expressions. So likely this is an issue with the composer.json

The error should be shown on the schema document and not on the document that is being validated.
I would say it's correct to ignore such regexes.
If we want to show a problem, then it would be a warning, and the message needs to be clear that this is an issue of the schema.

Something like 'Unable to validate value. Pattern {0} provided by the schema is not supported.'

@aedenmurray

Copy link
Copy Markdown
Contributor Author

Thanks Martin Aeschlimann (@aeschli)!
You are correct - this is an issue with composer.json.
However, the current implementation attempts to blame the user, which is misleading:
Screenshot 2025-04-25 at 7 55 29 PM
I agree with the sentiment that invalid patterns should be ignored.
I have updated the PR to match.

@vs-code-engineering vs-code-engineering Bot added this to the April 2025 milestone Apr 29, 2025
@aeschli
Martin Aeschlimann (aeschli) merged commit 4d43e6e into microsoft:main Jun 6, 2025
Steve Abbott Jr (sabbott1877) added a commit to analyst-one/vscode-json-languageservice that referenced this pull request Jul 21, 2026
* prepare 5.4.3 (microsoft#257)

* prepare 5.4.4 (microsoft#258)

* feat: make the capability of newJSONDocument and JSONDocument constructor consistent (microsoft#259)

* prepare 5.5.0 (microsoft#264)

* use https locations for all ols schema drafts (microsoft#268)

* feat: enhance JSON schema completion with enum sorting and details (microsoft#269)

* prepare 5.6.0 (microsoft#271)

* feat: Notify Invalid RegExp Patterns (microsoft#261)

* report problem if extendedRegExp catches an error

* only report invalid regex if needed

* add test for invalid patterns

* no optional chaining

* ignore invalid regex

* chore: bump action and node versions (microsoft#274)

* feat: allow format range to be undefined (microsoft#272)

* prepare 5.6.1 (microsoft#278)

* feat: examples completion for propertyNames (microsoft#286)

* update to @types/node:22x (microsoft#288)

* prepare 5.6.2 (microsoft#287)

* prepare 5.6.2

* update

* include bundled schemas 2020-12 & 2019-09 (microsoft#294)

* use flat 2019-09 and 2020-12 schemas (microsoft#295)

* prepare 5.6.3 (microsoft#296)

* Escape plain text description hover correctly (microsoft#283)

* Escape plain text description hover correctly

* Trim and escape `<`

* Update test

* Add PR description example as a test case

Removed `MarkedString.fromPlainText` as that escapes the input
and is not what we want here
(we use `toMarkdown` which isn't the same)

---------

Co-authored-by: Martin Aeschlimann <martinae@microsoft.com>

* Bump js-yaml from 4.1.0 to 4.1.1 (microsoft#297)

Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.1.0 to 4.1.1.
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](nodeca/js-yaml@4.1.0...4.1.1)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 4.1.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump glob (microsoft#298)

Bumps  and [glob](https://github.com/isaacs/node-glob). These dependencies needed to be updated together.

Updates `glob` from 10.4.5 to 10.5.0
- [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md)
- [Commits](isaacs/node-glob@v10.4.5...v10.5.0)

Updates `glob` from 11.0.3 to 11.1.0
- [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md)
- [Commits](isaacs/node-glob@v10.4.5...v10.5.0)

---
updated-dependencies:
- dependency-name: glob
  dependency-version: 10.5.0
  dependency-type: indirect
- dependency-name: glob
  dependency-version: 11.1.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* prepare 5.6.4 (microsoft#299)

* feat: make getMatchingSchemas return keys matching propertyNames schema (microsoft#279)

* feat: make getMatchingSchemas return keys matching propertyNames schema

* test: add test for schema matching on propertyNames

---------

Co-authored-by: Martin Aeschlimann <martinae@microsoft.com>

* feat: add discriminator support for JSON schema validation (microsoft#292)

* feat: implement discriminator optimization for JSON schema validation

* polish and extract common patterns

---------

Co-authored-by: Martin Aeschlimann <martinae@microsoft.com>

* prepare 5.7.0 (microsoft#301)

* prepare 5.7.0

* polish

* prepare 5.7.1, add DiagnosticRelatedInformation (microsoft#303)

* fix typo in `additionalProperties` JSON Schema property description (microsoft#310)

* Only escape to `&nbsp;` when needed (microsoft#309)

* prepare 5.7.2 (microsoft#311)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Martin Aeschlimann <martinae@microsoft.com>
Co-authored-by: MO <9125255+fengzilong@users.noreply.github.com>
Co-authored-by: Aeden Murray <aeden@aedenmurray.dev>
Co-authored-by: Raymond Zhao <7199958+rzhao271@users.noreply.github.com>
Co-authored-by: Danila Schelkov <54549682+danila-schelkov@users.noreply.github.com>
Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marco Pinton <34537387+marcopiii@users.noreply.github.com>
Co-authored-by: mohanram <mohankumarelec@gmail.com>
Co-authored-by: Neven Sajko <4944410+nsajko@users.noreply.github.com>
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.

4 participants