Skip to content

feat: separate structural and semantic schema validation - #542

Merged
mariajgrimaldi merged 9 commits into
mainfrom
MJG/support-json-schema
Oct 27, 2026
Merged

mariajgrimaldi merged 9 commits into
mainfrom
MJG/support-json-schema

Conversation

@mariajgrimaldi

@mariajgrimaldi mariajgrimaldi commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Description

Each contribution is now validated against the JSON Schema contract from #431, so the pipeline parses YAML, validates each document against the configured JSON Schema, and loads only structurally valid documents, while Python validation keeps semantic checks that require combined or compiled definitions, or the vendored Paragon icon names.

The JSON Schema now covers the structural rules previously implemented in Python (in validation.py):

  • versions, required fields, and value types;
  • identifiers and Casbin-prefix rejection;
  • scopes and collection shapes;
  • unknown fields and icon format.

Tests moved between the loading, parsing, syntax, and semantic suites with the same coverage, and the Python validators in validation.py still cover:

  • cross-contribution references;
  • duplicate conflicts and scope compatibility;
  • role extensions and compiled definitions;
  • Paragon icon membership.

How to test

From a Tutor LMS development container, at the mounted openedx-authz checkout root, run:

pytest -q -o addopts='' -p no:randomly --create-db --ds=cms.envs.test \
    src/openedx_authz/tests/integration/test_schema_pipeline.py

Fixes #459

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Oct 20, 2026
@openedx-webhooks

openedx-webhooks commented Oct 20, 2026 •

Copy link
Copy Markdown

Thanks for the pull request, @mariajgrimaldi!

This repository is currently maintained by @openedx/committers-openedx-authz.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Oct 20, 2026
@mariajgrimaldi
mariajgrimaldi force-pushed the MJG/support-json-schema branch 2 times, most recently from 67d5aec to 6efbdf9 Compare October 20, 2026 12:38
@mariajgrimaldi
mariajgrimaldi marked this pull request as ready for review October 20, 2026 13:01
@mariajgrimaldi
mariajgrimaldi force-pushed the MJG/support-json-schema branch from 9bef38e to 06b2c5d Compare October 21, 2026 19:12
@mariajgrimaldi mariajgrimaldi changed the title feat: separate structural and semantic schema validation feat: separate structural and semantic schema validation Oct 22, 2026

@BryanttV BryanttV 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.

Thanks, @mariajgrimaldi! The code looks great, thanks for your work on this! I tested it locally and it works perfectly. I just have one minor (non-blocking) comment.

log = logger.error if issue.is_error else logger.warning
log("authz schema %s: %s [%s]", issue.level, issue.message, issue.source_id or "-")
if self._validator.has_errors(issues):
if any(issue.is_error for issue in issues):

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.

Why not keep using has_errors here?

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.

It seems that has_errors was only used here, if we are not using it becomes dead code that should be cleaned up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We have two validators now, so the decision to stop belongs in _gate(). This avoids exposing the same error-checking API on both validators. I’ll remove the unused has_errors() method and its tests.

@mphilbrick211 mphilbrick211 moved this from Needs Triage to In Eng Review in Contributions Oct 22, 2026

@rodmgwgu rodmgwgu 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.

Looks great, thanks! I just have the same question as Bryann on the usage of the has_errors method

@carlos-marquez-wgu carlos-marquez-wgu 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.

Thanks for your work, @mariajgrimaldi ! I tested this locally and is working as expected

One non-blocking comment

  1. File src/openedx_authz/engine/schema/__init__.py still describes the pipeline lifecycle as discover -> load -> validate -> compile, some other places were updated to match the new one discover -> parse -> validate structure -> load -> validate semantics -> compile

def test_structural_errors_stop_before_typed_loading(self):
"""All structural findings stop loading and later lifecycle stages."""
errors = [
ValidationIssue("error", "bad first document", "first"),

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.

nit pic: Should these statements (and similar) use IssueLevel.ERROR instead raw string error?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed. Pipeline test fixtures now use IssueLevel.ERROR and IssueLevel.WARNING.

@mariajgrimaldi
mariajgrimaldi merged commit 9326beb into main Oct 27, 2026
8 checks passed
@mariajgrimaldi
mariajgrimaldi deleted the MJG/support-json-schema branch October 27, 2026 21:07
@github-project-automation github-project-automation Bot moved this from In Eng Review to Done in Contributions Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Extend schema loader validation to use schema reference defined in #431

6 participants