Skip to content

Added support for draft07 format conditional clauses with existing schema - #10487

Open
mahakjain314 wants to merge 1 commit into
Azure:mainfrom
mahakjain314:mahja/json-schema
Open

mahakjain314 wants to merge 1 commit into
Azure:mainfrom
mahakjain314:mahja/json-schema

Conversation

@mahakjain314

@mahakjain314 mahakjain314 commented Oct 19, 2026 •

Copy link
Copy Markdown

🤖 PR Validation — ️✔️ All clear

Breaking Changes
️✔️ None

This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

az migrate runbook parameter configure
az migrate runbook execution parameter configure

Summary

Add offline, client-side validation of optional JSON Schema Draft-07 clauses in
the shared runbook/execution parameter editor.

Root cause: the editor treated every entry in a step's mixed schema/parameter
map as an editable parameter and checked fields independently. Consequently,
schema keywords such as allOf could appear as parameters and cross-field
conditions were not evaluated.

  • Bundle @cfworker/json-schema 4.1.1 and the Draft-07 meta-schema, with the MIT
    license and pinned, reproducible npm/esbuild tooling. No browser network calls,
    runtime eval, new Python runtime dependency, or end-user Node.js requirement.
  • Separate standard schema keywords from editable parameters while preserving
    legacy parameter descriptors whose names match keywords.
  • Validate effective shared/per-workload values using the existing inheritance
    rules, and reuse the results for field errors, step/workload badges, the
    issue list, and upload-command readiness.
  • Show malformed/unsupported schemas and unresolved references as blocking errors.
    Validate authored schemas before adding parameter-property placeholders so an
    invalid properties clause cannot be normalized into a valid one.
  • Disable upload-command preparation/copying while schema errors exist; allow
    incomplete work to be saved explicitly as a draft. The HTML does not upload
    directly, and independently executed CLI uploads are not intercepted.
  • Preserve schema data on export and preserve legacy partial-update behavior
    when no optional schema clauses are supplied.
  • Bump migrate to 3.0.0b7 and update release history. Do not modify src/index.json.

Local generated JSON/HTML, wheel files, and temporary source-path debug logging
are intentionally excluded.

Validation

Commands use the repository's development Python environment. Unit and coverage
commands were also run against an archive of the exact committed PR source,
without unrelated local logging changes or generated build artifacts.

Working directory Command Result
src\migrate python -m pytest .\azext_migrate\tests\latest\runbook\test_runbook_unit.py -q Passed: 291 tests, including the generated-editor JavaScript runtime harness.
src\migrate python .\scripts\runbook_coverage.py Passed: 294 unit/scenario tests; 97% coverage, above the 95% gate.
Repository root python -m azdev style migrate Passed: pylint and flake8.
Repository root python -m azdev linter migrate Passed: no rule or custom pylint violations.
Repository root python .\scripts\ci\test_index.py -q Passed: 7 tests; 2 CI-only checks skipped.
src\migrate\scripts\schema-validator npm run build Passed: the rebuilt vendor bundle matched byte for byte.
Repository root git diff origin/main...HEAD --check Passed.
TOTAL  1915  58  97%

The JavaScript harness executes the generated inline script with string/WASM
code generation disabled. Its 11 runtime tests cover legacy behavior,
conditional requirements, entity overrides/inheritance, allOf/anyOf/oneOf/
not/if/then/else/dependencies, arrays, local references, malformed schemas,
prototype-property names, exports, draft saving, and upload-command gating.

Additional local headless Microsoft Edge verification passed: no script/CSP
errors or HTTP(S) requests, no allOf control, inline conditional errors and
recovery on editing, preserved exported schema, and legacy no-allOf behavior.

Engineering review

# Review point Decision
1 Selected design A small bundled Draft-07 interpreter keeps dynamically supplied schemas offline and compatible with the existing strict CSP.
2 Alternatives Ajv runtime compilation requires eval or a separate per-schema compilation step; other evaluated interpreters introduced larger/async integration without resolving all reference edge cases.
3 Existing code reused Shared renderer, legacy field rules, workload inheritance, issue navigation, save/export, and upload-command presentation.
4 Consolidation One cached step-issue path drives validation across fields, workloads, badges, summaries, and command readiness.
5 Duplicate logic removed Replaced repeated per-view validation loops with shared issue results.
6 New abstractions Schema preparation and SDK integration helpers only; no custom interpreter or per-condition handlers.
7 Net growth 1,087 lines added / 37 removed across 13 files, including the vendor bundle/license, official meta-schema, lockfile, tests, and release metadata.
8 Remaining debt Unresolved external references fail visibly offline. The SDK's unsupported $ref plus sibling $id combination is explicitly rejected. TODO(confirm): broader optional format/content conformance before claiming coverage beyond the SDK's documented support.
9 Maintenance score 9/10: pinned SDK, reproducible bundle, focused helpers, runtime regressions, and no end-user build dependency; known SDK limitations remain explicit.
10 Simplest correct solution Keep conditions in schema data and delegate evaluation to the SDK, while retaining existing field/UI behavior and avoiding service/API changes.

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install azdev required)
  • My extension version conforms to the Extension version schema

For new extensions:

Not applicable: this updates the existing migrate extension.

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

Bundle an offline validator, separate schema keywords from editable fields, validate effective workload inputs, and gate upload-command preparation on schema errors. Preserve legacy behavior and draft saving.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d53ebcbc-f948-464f-8d13-d12fbed0619f
Copilot AI balanced review requested due to automatic review settings October 19, 2026 09:21
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Oct 19, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution mahakjain314! We will review the pull request and get back to you soon.

@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

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.

🟡 Changes recommended

Unresolved references can bypass readiness blocking, and missing-property diagnostics can target the wrong input.

2 open issues
1 file not reviewed
  • src/migrate/scripts/schema-validator/package-lock.json: Generated file
What changed in this PR

Adds offline Draft-07 validation to the shared runbook and execution parameter editor.

Changes:

  • Bundles the validator and meta-schema with reproducible build tooling.
  • Integrates schema errors into editor feedback, upload-command gating, and draft saving.
  • Adds runtime coverage and updates release packaging.
File Description
src/​migrate/​setup.py Bumps version and packages vendor assets.
src/​migrate/​scripts/​schema-validator/​package.json Pins build dependencies.
src/​migrate/​scripts/​schema-validator/​package-lock.json Locks dependency resolution.
src/​migrate/​scripts/​schema-validator/​draft07.json Adds the Draft-07 meta-schema.
src/​migrate/​scripts/​schema-validator/​build.mjs Builds the offline validator bundle.
src/​migrate/​scripts/​schema-validator/​.gitignore Excludes installed dependencies.
src/​migrate/​HISTORY.rst Documents the release.
src/​migrate/​azext_migrate/​tests/​latest/​runbook/​test_runbook_unit.py Invokes JavaScript runtime checks.
src/​migrate/​azext_migrate/​tests/​latest/​runbook/​test_configure_schema.js Tests validation and editor behavior.
src/​migrate/​azext_migrate/​runbook/​configure/​vendor/​LICENSE Includes the validator license.
src/​migrate/​azext_migrate/​runbook/​configure/​vendor/​json-schema.js Supplies the bundled validator.
src/​migrate/​azext_migrate/​runbook/​configure/​templates/​configure.html.tmpl Integrates validation and readiness controls.
src/​migrate/​azext_migrate/​runbook/​configure/​renderer.py Embeds the validator in generated HTML.

Review effort: Balanced

Comment on lines +511 to +513
result.validator = new RunbookSchema.Validator(schema, '7', false);
result.validator.addSchema(RunbookSchema.metaSchema);
result.schema = schema;
Comment on lines +640 to +641
const required = e.keywordLocation.slice(2).split('/').reduce((s, k) => s && s[k.replace(/~1/g, '/').replace(/~0/g, '~')], prepared.schema);
if (Array.isArray(required)) f = required.find(k => !has(data, k)) || null;
@mahakjain314 mahakjain314 changed the title [migrate] Add offline Draft-07 validation to parameter editors Added support for draft07 format conditional clauses with existing schema Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants