Skip to content

fix: Monaco JSON schema validation not enforcing additionalProperties#185

Draft
Copilot wants to merge 4 commits into
developfrom
copilot/integrate-monaco-editor
Draft

fix: Monaco JSON schema validation not enforcing additionalProperties#185
Copilot wants to merge 4 commits into
developfrom
copilot/integrate-monaco-editor

Conversation

Copilot AI commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Monaco's JSON worker was silently ignoring the additionalProperties: false constraints defined throughout pr-filter-schema.ts, allowing arbitrary extra properties without any validation error.

Root causes

1. enableSchemaRequest not set → $ref resolution broken
Without enableSchemaRequest: false, Monaco's JSON worker attempted to fetch the schema from the uri field (https://pullrequest-manager.local/…). That address is unreachable, the fetch failed silently, and $ref resolution against the document root failed with it — meaning FilterNode, UserFilter, and ReviewerFilter definitions were never applied.

2. Custom-scheme fileMatch never matched
['pullrequest-manager:///profile-filter/*.json'] relied on Monaco's glob matcher treating the custom scheme as a literal prefix. It doesn't — the match failed and the schema was never associated with the editor model at all.

Fix

 monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
   validate: true,
   allowComments: false,
+  enableSchemaRequest: false,
   schemas: [{
     uri: SCHEMA_URI,
-    fileMatch: [`${SCHEMA_PATH_PREFIX}*.json`],
+    fileMatch: ['**'],
     schema: PR_FILTER_SCHEMA,
   }],
 })
  • enableSchemaRequest: false — forces Monaco to use the inline schema object directly, making $ref → #/definitions/* resolution work correctly.
  • fileMatch: ['**'] — universally matches any model URI, bypassing the custom-scheme matching issue. Since the profile filter editor is the only Monaco JSON editor in this renderer, the broad match is safe.

The additionalProperties: false constraints in pr-filter-schema.ts were already correct and needed no changes.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 20, 2026 16:33
…SON schema validation

Co-authored-by: NecatiMeral <7882753+NecatiMeral@users.noreply.github.com>
…safe optional chaining for matchMedia

Co-authored-by: NecatiMeral <7882753+NecatiMeral@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Monaco editor integration with JSON schema validation feat: Integrate Monaco editor for profile filter configuration with JSON schema validation Feb 20, 2026
Copilot AI requested a review from NecatiMeral February 20, 2026 16:39
…quest: false and using universal fileMatch

Co-authored-by: NecatiMeral <7882753+NecatiMeral@users.noreply.github.com>
Copilot AI changed the title feat: Integrate Monaco editor for profile filter configuration with JSON schema validation fix: Monaco JSON schema validation not enforcing additionalProperties Mar 7, 2026
@sonarqubecloud

sonarqubecloud Bot commented Mar 7, 2026

Copy link
Copy Markdown

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.

2 participants